Property

key

The key that was pressed.

KeyEventIsAltPressedSample

@Sampled
@Composable
fun KeyEventIsAltPressedSample() {
    Box(
        Modifier.onKeyEvent {
                if (it.isAltPressed && it.key == Key.A) {
                    println("Alt + A is pressed")
                    true
                } else {
                    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: