Class

KeyEventType

The type of Key Event.

KeyEventTypeSample

@Sampled
@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()
    )
}
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: