捕获所有按Ctrl - ? Android的下 [英] Capture all Ctrl-? under Android

查看:159
本文介绍了捕获所有按Ctrl - ? Android的下的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我修改ConnectBot利用硬件键盘,我需要捕获所有按Ctrl - ? presses。我已经停用​​所有的字母菜单快捷方式(例如Ctrl-C进行复制),但关键presses似乎仍然不能正由安其活动得到的。

I'm modifying ConnectBot to take advantage of hardware keyboards and I need to capture all Ctrl-? presses. I've disabled all of the alphabetic menu shortcuts (such as Ctrl-C for copy) but the key presses still don't seem to be being received by the onKey event.

我是相当新的Andr​​oid开发(字面上今天开始修复ConnectBot处理硬件键盘)和快速谷歌搜索似乎并没有露面有关捕获按Ctrl - 什么?关键presses。

I'm fairly new to Android development (literally started today to fix ConnectBot to handle hardware keyboards) and quick Google searching doesn't seem to turn up anything about capturing Ctrl-? key presses.

我怎么知道Android的直接传送到安其处理器来传递这些?

How do I tell Android to pass these straight through to the onKey handler?

推荐答案

原来,关键code被设置为正确的字符值(例如'C')。然而,getUni codeCHAR()的结果是0,因为CTRL当时正在举行。

It turns out that the keyCode was set to the correct character value (e.g. 'C'). However, the result of getUnicodeChar() was 0 because CTRL was being held.

所有这一切需要的是增加处理,以获得UNI code字不管正在举行打倒元键:

All that was needed was to add handling to get the unicode character regardless of the meta-keys that are being held down with:

if (event.isCtrlPressed())
    event = new KeyEvent(KeyEvent.ACTION_DOWN, keyCode);

然后被按下CTRL后来是必要的EN code中的关键数据正被发送的信息,这是已经被ConnectBot code提供的功能。

Then later on it was necessary to encode the "CTRL is being held down" information in the key data that was being sent, which was already functionality provided by the ConnectBot code.

这篇关于捕获所有按Ctrl - ? Android的下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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