Getting proper text input from physical keyboard in Android

痴心易碎 提交于 2019-12-24 10:58:32

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!