androidx.compose.ui.input.key

onPreviewKeyEvent

Function · from org.jetbrains.compose.ui:ui:1.12.2

No hand-written docs yet.

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

Parameters

fun Modifier.onPreviewKeyEvent(onPreviewKeyEvent: (KeyEvent) -> Boolean): Modifier

onPreviewKeyEvent: (KeyEvent) -> BooleanRequired

This callback is invoked when the user interacts with the hardware keyboard. It gives ancestors of a focused component the chance to intercept a KeyEvent. Return true to stop propagation of this event. If you return false, the key event will be sent to this onPreviewKeyEvent's child. If none of the children consume the event, it will be sent back up to the root KeyInputModifierNode using the onKeyEvent callback.

Library docs

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