Reputation: 33
I am struggling on sending combination key like "ctrl" + "a" on my samsung J7 with android 8.1.0.
After finding resources in the Internet, I found some commands that help sending text via ADB such as:
adb shell input keyevent 29 => a
adb shell input text "a" => a
However, when I used sendevent to send text "a", it didn't work (The same as "ctrl" + "a"). My command is below:
adb shell sendevent /dev/input/event6 1 30 1 => Key down.
adb shell sendevent /dev/input/event6 0 0 0 -> End report.
adb shell sendevent /dev/input/event6 1 30 0 => Key up.
adb shell sendevent /dev/input/event6 0 0 0 => End report.
Then I checked keycode followed by link, I executed the command:
adb shell getevent -p
The output is:
add device 1: /dev/input/event2
name: "accelerometer_sensor"
events:
REL (0002): 0000 0001 0002 0007 0009
input props:
<none>
add device 2: /dev/input/event3
name: "proximity_sensor"
events:
ABS (0003): 0019 : value 1, min 0, max 1, fuzz 0, flat 0, resolution 0
input props:
<none>
add device 3: /dev/input/event6
name: "sec_touchscreen"
events:
KEY (0001): 0145* 014a
ABS (0003): 0000 : value 0, min 0, max 1079, fuzz 0, flat 0, resolution 0
0001 : value 0, min 0, max 1919, fuzz 0, flat 0, resolution 0
002f : value 0, min 0, max 9, fuzz 0, flat 0, resolution 0
0030 : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
0031 : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
0035 : value 0, min 0, max 1079, fuzz 0, flat 0, resolution 0
0036 : value 0, min 0, max 1919, fuzz 0, flat 0, resolution 0
0039 : value 0, min 0, max 65535, fuzz 0, flat 0, resolution 0
003e : value 0, min 0, max 1, fuzz 0, flat 0, resolution 0
input props:
INPUT_PROP_DIRECT
add device 4: /dev/input/event4
name: "Codec3026 Headset Events"
events:
KEY (0001): 0072 0073 00e2 0246
input props:
<none>
add device 5: /dev/input/event0
name: "meta_event"
events:
REL (0002): 0006 0007
input props:
<none>
could not get driver version for /dev/input/mice, Not a typewriter
add device 6: /dev/input/event1
name: "sec_touchkey"
events:
KEY (0001): 009e 00fe
LED (0011): 0008
input props:
<none>
add device 7: /dev/input/event5
name: "gpio_keys"
events:
KEY (0001): 0072 0073 0074 00ac
input props:
<none>
The output means the device /dev/input/event6 does not have keyevent for inputting texts.
So my question is: How can I implement combination key with keydown and keyup separately?
Thanks so much for helping.
Upvotes: 1
Views: 1384
Reputation: 33
After doing a lot of research, I figured out the root cause is from meta key code.
I tried to use a third party application, but the origin version couldn't send meta key codes correctly on Android 8+.
Therefore, I made some changes and then requested a pull ticket as issue. During waiting for merging, I publish the modified version in my repo in case anyone needs it. You can download only ADBKeyboard.apk on this repo since it is updated though.
Now I can send Ctrl + A as below: (4096 is META_CONTROL_ON, 29 is KEYCODE_A)
adb shell am broadcast -a ADB_INPUT_TEXT --es mcode '4096,29'
Upvotes: 0