问题
I have a View
that overrides the OnKeyDown
event. I can get the Key Code and the KeyEvent, but it seems that I'm missing something.
Let me explain. For non-US keyboard layouts, the Key Code I'm getting is wrong. For example, when I press the ñ key in my Spanish keyboard, I expect to receive a "ñ" letter, but instead I get a Keycode.AltLeft
as Key Code.
How do I get the real letter?
Another problematic case is with accentuated characters: When I press the ´ key and the o key, I shouldn't receive two events, but only one with the letter ó.
回答1:
What are you trying to do? It is probably too low level. A key down might not necessarily have anything to do with the final input text produced. For instance to produce on Japanese character one has to press a sequence of several keys.
来源:https://stackoverflow.com/questions/44552029/getting-proper-text-input-from-physical-keyboard-in-android