从Android中的物理键盘获取正确的文本输入 [英] Getting proper text input from physical keyboard in Android

查看:74
本文介绍了从Android中的物理键盘获取正确的文本输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个View覆盖了OnKeyDown事件.我可以获得密钥代码和KeyEvent,但似乎我缺少了一些东西.

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.

让我解释一下.对于非美国键盘布局,我得到的键码"是错误的.例如,当我按下西班牙文键盘中的ñ键时,我希望收到一个ñ"字母,但是却得到了Keycode.AltLeft作为键码.

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?

另一种有问题的情况是加重字符:当我按´键和o键时,我不会收到两个事件,而只有一个带有字母ó的事件.

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 ó.

推荐答案

您要做什么?这可能是太低的水平. 按下按键不一定与产生的最终输入文本有任何关系.例如,要制作日语字符,必须按几个键的顺序.

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.

这篇关于从Android中的物理键盘获取正确的文本输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆