---
title: "indexForKey"
description: "The index of an item identified by a given key. The key is usually defined during the creation of
the container. If the key did not match any of the items' keys, the [mapping] must return -1."
type: "function"
---

<div class='type'>Function</div>


<a id='references'></a>
<div class='sourceset sourceset-common'>Common</div>


```kotlin
fun SemanticsPropertyReceiver.indexForKey(mapping: (Any) -> Int)
```


The index of an item identified by a given key. The key is usually defined during the creation of
the container. If the key did not match any of the items' keys, the `mapping` must return -1.



