无法从Android的KeyEvent的获取元状态 [英] Can't get meta state from Android KeyEvent

查看:173
本文介绍了无法从Android的KeyEvent的获取元状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看起来很傻,但我不能让元的状态出来的KeyEvent,从onKeyListener访问的。试图与我拥有所有键盘和模拟器。

Looks silly, but I can't get meta state out of KeyEvent, accessed from onKeyListener. Tried with all keyboards I have and with emulators.

不管是不是Shift,Ctrl等键是pressed,KeyEvent.getMetaState()函数返回0,可它工作的TextListener,但我并不需要它的输入文字,我只想标签来区分和Shift + Tab键。

Whether or not Shift, Ctrl, etc keys are pressed, keyEvent.getMetaState() returns 0. May it works for TextListener, but I don't need it for entering text, I just want to differentiate between Tab and Shift+Tab.

感谢您的预期帮助。

更新。的我只是想出的是,元州报告了字母键,但不为其他键。

Update. What I just figured out is that meta state is reported for alphabetic keys, but not for other keys.

例如,如果我preSS左Shift + T系统生成的KeyEvent重点code_SHIFT_LEFT和KEY code_T和KeyEvent的关键code_T有META_SHIFT_ON集。你可以欺骗使用Shift + TAB + T系统,在这种情况下META_SHIFT_ON设置为KEY code_T和KEY code_TAB。然而,随着Shift + Tab该KeyEvent关键code_SHIFT_LEFT不产生,和元状态不受影响。

For example if I press left Shift+T the system generates KeyEvent for KEYCODE_SHIFT_LEFT and KEYCODE_T, and KeyEvent for KEYCODE_T has META_SHIFT_ON set. You can trick the system with Shift+TAB+T, in which case META_SHIFT_ON is set for both KEYCODE_T and KEYCODE_TAB. However with Shift+TAB the KeyEvent for KEYCODE_SHIFT_LEFT is not generated, and the meta state remains unaffected.

也许系统键盘配置文件需要进行更新,以允许像Shift + Tab组合?

Maybe system keyboard configuration files need to be updated to allow combinations like Shift+TAB?

推荐答案

是的,这真的Andr​​oid的配置文件。

Yes, it's really about android configuration file.

您修改/system/usr/kychars/Generic.kcm TAB条目(或相应供应商提供的文件),并添加一行的转变,如下所示:

You modify TAB entry in /system/usr/kychars/Generic.kcm (or the file for corresponding vendor) and add a line for shift, as the following:

key TAB {
    label:                              '\t'
    base:                               '\t'
    shift:                              '\t'
    ctrl, alt, meta:                    none
}

一些设备使用qwerty.kcm,其具有换档线alaready present。他们应该没有入侵工作确定。 BTW,UNI code的规定Shift + Tab键一个特殊的code \\ u21B9,但它可能不是由Android的认可。

Some devices uses qwerty.kcm, which has the shift line alaready present. They should work OK without intrusion. BTW, unicode has provides a special code \u21B9 for Shift+TAB, but it might not be recognised by Android.

这篇关于无法从Android的KeyEvent的获取元状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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