Google se compromete a impulsar la igualdad racial para las comunidades afrodescendientes. Obtén información al respecto.

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
Key(nativeKeyCode: Int)

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

Key

fun Key(nativeKeyCode: Int): Key

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

isAltPressed

actual val KeyEvent.isAltPressed: Boolean

Indicates whether the Alt key is pressed.

isCtrlPressed

actual val KeyEvent.isCtrlPressed: Boolean

Indicates whether the Ctrl key is pressed.

isMetaPressed

actual val KeyEvent.isMetaPressed: Boolean

Indicates whether the Meta key is pressed.

isShiftPressed

actual val KeyEvent.isShiftPressed: Boolean

Indicates whether the Shift key is pressed.

key

actual val KeyEvent.key: Key

The key that was pressed.

nativeKeyCode

val Key.nativeKeyCode: