Capturing all Ctrl-? under Android

I am modifying ConnectBot to use the hardware keys and I need to grab all the Ctrl-? the press. I disabled all the shortcuts of the alphabetical menu (e.g. Ctrl-C for copying), but the keystroke is still not sensed by the onKey event.

I'm new to Android development (it literally started today to fix ConnectBot for handling hardware keyboards), and a quick google search doesn't seem to show anything about capturing Ctrl-? keystrokes.

How can I tell Android to pass this directly to the onKey handler?

+1
source share
1 answer

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

All that was needed was to add processing to get the unicode character, regardless of the meta keys that are held with:

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

Then later it was necessary to encode the information "CTRL held" in the transmitted key data, which was already functional, provided by the ConnectBot code.

+1
source

Source: https://habr.com/ru/post/1341395/


All Articles