Android: how to intercept key event with key code KEYCODE_META_LEFT from a physical keyboard

2

I am analyzing the keyEvents generated by Bluetooth QWERTY keyboard connected to my Nexus 5 device. I could get all the key strokes except Windows key to working.

Keyboard input device is configured as

Bluetooth 3.0 Keyboard Classes: 0x80000003 Path: /dev/input/event6 Descriptor: c9a38dcf18d4596752ec436bf05aa70be1fe36b0 Location: ControllerNumber: 0 UniqueId: 25:95:20:00:73:EE Identifier: bus=0x0005, vendor=0x04e8, product=0x7021, version=0x0001 KeyLayoutFile: /system/usr/keylayout/Generic.kl KeyCharacterMapFile: /system/usr/keychars/Generic.kcm ConfigurationFile: HaveKeyboardLayoutOverlay: false

And the Windows key is generating the following scan code and its corresponding android key code when pressed.

EV_MSC MSC_SCAN 000700e3
EV_KEY KEY_LEFTMETA DOWN
EV_SYN SYN_REPORT 00000000
EV_MSC MSC_SCAN 000700e3
EV_KEY KEY_LEFTMETA UP
EV_SYN SYN_REPORT 00000000

This KEYCODE_META_LEFT is being consumed by Google apps. No matter what I do this is launching the Google Now on Tap / search.

I have tried the following approaches but no luck yet
1. Tried overriding the search functionality within my activity in the hope to capture this keyEvent.
2. Tried almost all the key event dispatch methods like dispatchKeyEventPreIme etc. to intercept it. 3. Disabled Now on tap, now cards. Installed custom launcher and removed the search widget on the home screen. Still this launches the search view.

Would be of great help if you can point me in the right direction here

Not interested in changing the key layout file which works only rooted devices.
Looking for an approach which works without tweaking the stock ROM.

android
keyboard
asked on Stack Overflow Jul 27, 2016 by Chandra Mouli

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0