---
title: "KeyEventType"
description: "The type of Key Event."
type: "class"
---

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


<a id='references'></a>

<div class='sourceset sourceset-common'>Common</div>


```kotlin
value class KeyEventType internal constructor(@Suppress("unused") private val value: Int)
```


The type of Key Event.


## Companion Object

#### Properties

<div class='sourceset sourceset-common'>Common</div>


```kotlin
val Unknown: KeyEventType
```


Unknown key event.



<div class='sourceset sourceset-common'>Common</div>


```kotlin
val KeyUp: KeyEventType
```


Type of KeyEvent sent when the user lifts their finger off a key on the keyboard.



<div class='sourceset sourceset-common'>Common</div>


```kotlin
val KeyDown: KeyEventType
```


Type of KeyEvent sent when the user presses down their finger on a key on the keyboard.





## Code Examples

### KeyEventTypeSample
```kotlin
@Composable
fun KeyEventTypeSample() {
    Box(
        Modifier.onKeyEvent {
                when (it.type) {
                    KeyUp -> println("KeyUp Pressed")
                    KeyDown -> println("KeyUp Pressed")
                    Unknown -> println("Unknown key type")
                    else -> println("New KeyType (for future use)")
                }
                false
            }
            .focusable()
    )
}
```

