https://kotlinlang.org logo
#compose
Title
# compose
e

Enahor Tapmas

02/24/2024, 6:50 AM
Copy code
Window(onCloseRequest = ::exitApplication,         onKeyEvent = {
        if (it.key == Key.Escape && escEventAllowed){
            escEventAllowed = false
            println("ESC")
                            BackPressureHandler.execute()

            Thread {
                println("escHold")
                Thread.sleep(WAIT_FOR_ESC)
                println("escRelease")
                escEventAllowed = true
            }.start()
        }
        false
    })
I am using the onKeyEvent ability when I create my Window for the desktop main. It is registering escape multiple times instead of just once, and the thread is not helping, any ideas?
i

Ivan Matkov

02/24/2024, 9:38 AM
Press + Release events
e

Enahor Tapmas

02/24/2024, 12:33 PM
Any way to see what type of event I got?
i

Ivan Matkov

02/24/2024, 12:38 PM
Copy code
it.type == KeyEventType.KeyDown
e

Enahor Tapmas

02/25/2024, 5:48 AM
Thanks for the help, I believe its working 🙂
👍 1