6

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.

Mahoni
  • 7,088
  • 17
  • 58
  • 115

1 Answers1

5

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

Nimish Choudhary
  • 2,048
  • 18
  • 17
  • I have **[this](https://gist.githubusercontent.com/mahendranv/0958a2cbda303191c507/raw/22c6443d1cb1d1ebd03656e3ee9b030b10d82cb7/CTRL+N)** snippet for Ctrl+N not working. Any Idea ? – Mahendran May 26 '14 at 08:55
  • what are you planing to do with Ctrl* also do you get the ctrl on your android device. If so you might want to write the program and get the actual keycode on android device. – Nimish Choudhary Jun 10 '14 at 16:32
  • In my application I am using set of shortcuts Ctrl+N, Ctrl+C also verified the keycode is correct. – Mahendran Jun 11 '14 at 04:45