Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simulated two keyevents with adb shell for ALT, SHIFT, etc

Tags:

android

adb

With adb shell input keyevent certain key events can be simulated. There are also modifier keys like SHIFT_LEFT, ALT_RIGHT etc.

I would like to simulate two keys, for instance SHIFT + A, but

 adb shell input keyevent SHIFT_LEFT; keyevent A

results only in a simple a on the screen.

like image 902
Mahoni Avatar asked Jan 10 '13 14:01

Mahoni


1 Answers

if Shift + A is needed then you will have to do following sequence

Press shift
Press A
Release A
Release shift

this can be done by using

command format: sendevent device type code value

[command]     [device]             [type]    [code]   [value]
sendevent    /dev/input/event0    1          229      1

/dev/input/event0 is the device to send it to

[type] 1 is unknow for me ( maybe code for physical button on device )

[code] 229 is the MENU button of the emulator

[value] 1 is keydown or press down ( for keyup or up use 0 )

i wrote a batch file for sending the event to the device like below:

adb -s emulator-5554 shell sendevent /dev/input/event0 1 229 1
adb -s emulator-5554 shell sendevent /dev/input/event0 1 229 0

Ref

like image 172
Nimish Choudhary Avatar answered Oct 01 '22 19:10

Nimish Choudhary