by @alexstyl
✉️ Leave your feedback

← Back to Compose UI

previewKeyInputFilter

Modifier
in
Compose UI
. Since 0.1.0-dev15

Overview

Examples

Community Notes

Adding this modifierModifier to the modifierModifier parameter of a component will allow it to intercept hardware key events.

@param onPreviewKeyEvent 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 previewKeyInputFilter's child. If none of the children consume the event, it will be sent back up to the root KeyInputModifier using the onKeyEvent callback.

Overloads

previewKeyInputFilter

@Deprecated(
    message = "Use Modifier.onPreviewKeyEvent() instead",
    replaceWith = ReplaceWith(
        "onPreviewKeyEvent(onPreviewKeyEvent)",
        "androidx.compose.ui.input.key.onPreviewKeyEvent"
    ),
    level = DeprecationLevel.ERROR
)
fun Modifier.previewKeyInputFilter(onPreviewKeyEvent: (KeyEvent) -> Boolean)

Parameters

NameDescription
onPreviewKeyEventThis 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 previewKeyInputFilter's child. If none of the children consume the event, it will be sent back up to the root KeyInputModifier using the onKeyEvent callback
Next ComponentAndroidView