There is any API to listen to keyboard events in b...
# compose-desktop
s
There is any API to listen to keyboard events in background in Compose Desktop? example: for opening the window with a shortcut?
k
I hope not for the sake of protecting your passwords
s
I'm trying to do a spotlight application like for Linux.
r
This is the only thing I've seen for that: https://github.com/kwhat/jnativehook You might be better off in the long run instruction users to set up a global shortcut themselves and reacting to that somehow, although I'm not sure how you would do that either (a short lived process that sends something to a socket maybe?)
s
At the end, a better solution would be doing something using IPC for sure, but for testing, jnativehook will be enough for now, thanks :D
t
The new Window API has
Copy code
onPreviewKeyEvent: (KeyEvent) -> Boolean = { false },
onKeyEvent: (KeyEvent) -> Boolean = { false },
However, these only work when the window is focused, e.g. you want to open a second window via shortcut.