dkim
02/12/2022, 9:38 PMapplication {
Window(
onCloseRequest = ::exitApplication,
title = "App",
onKeyEvent = {
println("keyTyped: ${it.key.nativeKeyCode}:${it.key.nativeKeyCode.toChar()}")
false
}
) {
// Window stuff
}
}
Logs:
keyTyped: 65:A
keyTyped: 0:
keyTyped: 65:A
Using keyCode
instead would just give this output (pressing a):
keyTyped: 279709745152:
keyTyped: 536870912:
keyTyped: 279709745152:
Kirill Grouchnikov
02/12/2022, 9:55 PM${it.nativeKeyEvent}
Kirill Grouchnikov
02/12/2022, 9:55 PMPRESSED
, one TYPED
and one RELEASED
- which is what AWT produces for key eventsKirill Grouchnikov
02/12/2022, 9:58 PMval nativeKeyEvent = it.nativeKeyEvent as java.awt.event.KeyEvent
This will give you the AWT event. Then you can look at its id
and compare it to KeyEvent.KEY_TYPED
etcdkim
02/12/2022, 9:58 PMdkim
02/12/2022, 9:59 PMKirill Grouchnikov
02/12/2022, 10:27 PM