Does Android (or androidx) have a way to add multi...
# compose-android
a
Does Android (or androidx) have a way to add multiple key listeners for hardware keyboard/d-pad? I am trying to handle key presses in my jetpack compose composable and I don't have an
Activity
to override. So far I've found
View#setOnKeyListener
which works. I'm hesitant of using it, since I am working on a library and I don't want to override any existing listeners, or others overriding my listener.
z
Jetbrains is working on adding an api for keyboard shortcuts, would that work for your use case? https://github.com/JetBrains/compose-multiplatform-core/commit/a93a15772a88f577fc0cff3c5ef58a468e7494b8
a
@Zach Klippenstein (he/him) [MOD] I am not sure what I am looking at to be frank. where should i focus?
z
Eg
a
I ended up looking the whole thing. from an api POV, then maybe? if that works w/o requiring focus then it should be work for my case. I had a look at the implementation and i couldnt figure out how it works. getting late so ill check again tomorrow
z
What are you trying to build? If it’s some version of “commands”, this should help and any feedback you have for them might be useful.
a
I am building a Dropdown Menu component (for demo click here). There was this bug where opening the popup would not focus on the popup content, so pressing down/up would not move the focus in the list. I fixed it by handling the key presses on the platform level as it does not require focus. See this commit
z
Oh, ok I think that’s entirely different
a
I think I saw in a few places in the API about 'keyboard shortcuts' but i still don't get what they are. How are they different to key events?
z
Well, I don’t think you’d get raw events, you just be notified that some combination of keys was pressed.
👍 1