← Back to Compose UI
onInterceptKeyBeforeSoftKeyboard
Modifier
in
Compose UI
. Since 1.5.0-beta03Overview
Examples
Community Notes
@Composable
fun KeyEventSample() {
// When the inner Box is focused, and the user presses a key, the key goes down the hierarchy
// and then back up to the parent. At any stage you can stop the propagation by returning
// true to indicate that you consumed the event.
Box(
Modifier
.onPreviewKeyEvent { keyEvent1 -> false }
.onKeyEvent { keyEvent4 -> false }
) {
Box(
Modifier
.onPreviewKeyEvent { keyEvent2 -> false }
.onKeyEvent { keyEvent3 -> false }
.focusable()
)
}
}
Next ComponentAndroidView →