Julow / Unexpected-Keyboard

A lightweight virtual keyboard for developers.
GNU General Public License v3.0
1.47k stars 188 forks source link

Can I send keyevents? #717

Open dingodoppelt opened 3 months ago

dingodoppelt commented 3 months ago

Hi there, sorry for posting a question rather than an issue. I need to send a custom keyevent to an app, which I currently achieve by adb shell input keyevent 82. Is it possible to assign a keyevent to a key in a custom layout? cheers, nils

ChiefMikeK commented 3 months ago

Javascript Char Codes (Key Codes) - Cambia Research https://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes
doesn't r work?

dingodoppelt commented 3 months ago

Javascript Char Codes (Key Codes) - Cambia Research https://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes doesn't r work?

Those are keycodes, what I mean are android keyevents. In my partiular case I'm using an old app that relies on a Menu button to be present. Android doesn't have the menu button anymore (the app is VERY old ;) but I can still open the menu by sending the keyevent via adb. My question was, if unexpected keyboard has the ability to send keyevents (which are not keycodes) to an android app.

edit: https://developer.android.com/reference/android/view/KeyEvent

Julow commented 3 months ago

That's not possible at the moment but would be a great addition to the app. Would you be willing to implement it ?

The KeyValue class can already represent the new key and we just need a way to construct it. KeyValue.getKeyByName would be the best place to implement the new key syntax. The syntax should also allow specifying a label for the key. The custom key option do not use this getKeyByName function and instead makes raw string keys. It should be able to recognize the syntax too.

dingodoppelt commented 3 months ago

That's not possible at the moment but would be a great addition to the app. Would you be willing to implement it ?

I'm not a programmer, but I got #726 to do what I need :) Is this something you can make use of? cheers, nils

Julow commented 3 months ago

Thanks for the PR! That's the perfect way to solve your problem. I'd like to keep this issue open for discussing the other key events.

dingodoppelt commented 3 months ago

Thanks for the PR! That's the perfect way to solve your problem. I'd like to keep this issue open for discussing the other key events.

Thanks! Very much appreciated :)

ChiefMikeK commented 3 months ago

Thanks for the PR! That's the perfect way to solve your problem. I'd like to keep this issue open for discussing the other key events.

remember to update the docs.md 👌