androidx.compose.ui.input.key
Classes
Key |
Actual implementation of Key for Android. |
KeyEvent |
When a user presses a key on a hardware keyboard, a KeyEvent is sent to the KeyInputModifier that is currently active. |
Enums
KeyEventType |
The type of Key Event. |
Top-level functions summary
Key |
Extension functions summary
For Modifier | |
Modifier |
Modifier.onKeyEvent(onKeyEvent: (KeyEvent) -> Boolean) Adding this modifier to the modifier parameter of a component will allow it to intercept hardware key events. |
Modifier |
Modifier.onPreviewKeyEvent(onPreviewKeyEvent: (KeyEvent) -> Boolean) Adding this modifier to the modifier parameter of a component will allow it to intercept hardware key events. |
Extension properties summary
For KeyEvent | |
actual Boolean |
Indicates whether the Alt key is pressed. |
actual Boolean |
Indicates whether the Ctrl key is pressed. |
actual Boolean |
Indicates whether the Meta key is pressed. |
actual Boolean |
Indicates whether the Shift key is pressed. |
actual Key |
The key that was pressed. |
actual KeyEventType |
The type of key event. |
actual Int |
The UTF16 value corresponding to the key event that was pressed. |
For Key | |
Int |
The native keycode corresponding to this Key. |
Top-level functions
Extension functions
onKeyEvent
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.
Parameters | |
---|---|
onKeyEvent: (KeyEvent) -> Boolean | 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. |
onPreviewKeyEvent
fun Modifier.onPreviewKeyEvent(onPreviewKeyEvent: (KeyEvent) -> Boolean): Modifier
Adding this modifier to the modifier parameter of a component will allow it to intercept hardware key events.
Parameters | |
---|---|
onPreviewKeyEvent: (KeyEvent) -> Boolean | 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 KeyInputModifier using the onKeyEvent callback. |
Extension properties
isShiftPressed
actual val KeyEvent.isShiftPressed: Boolean
Indicates whether the Shift key is pressed.