What are the requirements for a node to receive ke...
# jewel
f
What are the requirements for a node to receive keyboard input? Just adding
onPreviewKeyEvent
to an empty box doesn't seem to receive any keyboard input events:
Copy code
fun main() {
    application {
        DecoratedWindow(onCloseRequest = ::exitApplication) {
            //TitleBar {}
            Box(Modifier.onPreviewKeyEvent { event ->
                println(event) // never prints anything
                false
            })
        }
    }
}
s
Compose only delivers keyboard events in the focused tree. If you want to capture key events even when not focused you probably need to use an AWT listener.
👍 1