Class

KeyEvent

When a user presses a key on a hardware keyboard, a KeyEvent is sent to the item that is currently focused.

Source set: Common
@kotlin.jvm.JvmInline public class KeyEvent(public val nativeKeyEvent: NativeKeyEvent)

When a user presses a key on a hardware keyboard, a KeyEvent is sent to the item that is currently focused. Any parent composable can intercept this key event on its way to the focused item by using Modifier.onPreviewKeyEvent()]onPreviewKeyEvent. If the item is not consumed, it returns back to each parent and can be intercepted by using Modifier.onKeyEvent()]onKeyEvent.

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: