androidx.compose.ui.input.key
Classes
Key |
Actual implementation of Key for Android. |
Type-aliases
NativeKeyEvent |
The native Android KeyEvent. |
Top-level functions summary
Key |
Top-level properties summary
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. |
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
Top-level functions
Top-level properties
isShiftPressed
actual val KeyEvent.isShiftPressed: Boolean
Indicates whether the Shift key is pressed.
utf16CodePoint
actual val KeyEvent.utf16CodePoint: Int
The UTF16 value corresponding to the key event that was pressed. The unicode character takes into account any meta keys that are pressed (eg. Pressing shift results in capital alphabets). The UTF16 value uses the U+n notation of the Unicode Standard.
An Int is used instead of a Char so that we can support supplementary characters. The Unicode Standard allows for characters whose representation requires more than 16 bits. The range of legal code points is U+0000 to U+10FFFF, known as Unicode scalar value.
The set of characters from U+0000 to U+FFFF is sometimes referred to as the Basic Multilingual Plane (BMP). Characters whose code points are greater than U+FFFF are called supplementary characters. In this representation, supplementary characters are represented as a pair of char values, the first from the high-surrogates range, (\uD800-\uDBFF), the second from the low-surrogates range (\uDC00-\uDFFF).
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. |