isAltPressed

Property

Common
expect val KeyEvent.isAltPressed: Boolean

Indicates whether the Alt key is pressed.

Common
expect val PointerKeyboardModifiers.isAltPressed: Boolean

true when the Alt key is pressed. This is commonly associated with the Option key on some keyboards.

Android
actual val KeyEvent.isAltPressed: Boolean

Indicates whether the Alt key is pressed.

Android
actual val PointerKeyboardModifiers.isAltPressed: Boolean

Code Examples

KeyEventIsAltPressedSample

@Composable
fun KeyEventIsAltPressedSample() {
    Box(
        Modifier.onKeyEvent {
                if (it.isAltPressed && it.key == Key.A) {
                    println("Alt + A is pressed")
                    true
                } else {
                    false
                }
            }
            .focusable()
    )
}