Reputation: 10891
How can you send multiple key events to the adb shell of the same key? For example, you can issue one 'delete' key event (#67) like this:
adb shell input keyevent 67
But is there something like this (note: this won't work)?
adb shell input keyevent 67 67
Upvotes: 5
Views: 14109
Reputation: 3199
If you are concerned about speed, I suggest using the sendevent command to send an event. I've found it to be significantly faster especially when it comes to simulating a tap.
Example
sendevent /dev/input/event18 1 67 1 // send key down event 67
sendevent /dev/input/event18 0 0 0 // end of report
sendevent /dev/input/event18 1 67 0 // send key up event 67
sendevent /dev/input/event18 0 0 0 // end of report
SYNTAX
sendevent <device> <type> <code> <value>
NOTE
This is sending events at a low level, which can give a lot of control and also flexibility to make it efficient by sending the exact events you are interested in. A big drawback, in my opinion, is the fact that you'll have to determine the device on your own (probably by using getevent command and manually figuring it out) The device /dev/input/event18 is just an example I used from my phone, this isn't constant.
For reference to valid arguments, you can see the header file. https://android.googlesource.com/platform/external/kernel-headers/+/8bc979c0f7b0b30b579b38712a091e7d2037c77e/original/uapi/linux/input.h
Upvotes: 2
Reputation: 2019
Try to use
adb shell "input keyevent 67 && input keyevent 67"
If you need to write large scripts, you can also try this approach.
Upvotes: 12