Compose Modifier

onKeyEvent

Adding this modifierModifier to the modifierModifier parameter of a component will allow it to intercept hardware key events when it (or one of its children) is focused.

onKeyEvent

Source set: Common
fun Modifier.onKeyEvent(onKeyEvent: (KeyEvent) -> Boolean): Modifier

Adding this modifier to the modifier parameter of a component will allow it to intercept hardware key events when it (or one of its children) is focused.

Parameters

onKeyEvent This callback is invoked when the user interacts with the hardware keyboard. While implementing this callback, return true to stop propagation of this event. If you return false, the key event will be sent to this onKeyEvent's parent.

Last updated: