Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does "adb shell input text" simulate software keyboard input?

adb shell input text "sometext"

OR

adb shell input keyevent eventid

do these simulate actual input from a virtual/ hardware keyboard respectively ?

I did not find any documentation for these commands on developer.android.com/

Is there any trusted documentation for these commands?

like image 762
l'-'l Avatar asked Sep 11 '14 08:09

l'-'l


People also ask

What is adb input?

ADB is Android Debug Bridge which is a command line utility included with Google's Android SDK. It provides a terminal interface to control your Android device connected to a computer using a USB. ADB can be used to run shell commands, transfer files, install/uninstall apps, reboot and more.


1 Answers

adb shell input help produces (after a long list of input devices):

The commands and default sources are:
  text <string> (Default: touchscreen)
  keyevent [--longpress] <key code number or name> ... (Default: keyboard)
  tap <x> <y> (Default: touchscreen)
  swipe <x1> <y1> <x2> <y2> [duration(ms)] (Default: touchscreen)
  press (Default: trackball)
  roll <dx> <dy> (Default: trackball)

So it seems "text" is indeed for virtual (Default: touchscreen) and keyevent for physical (Default: keyboard).

You can override the text input device - adb shell input keyboard text "foo" works just fine. You can't send raw keycodes from the screen though.

like image 128
SF. Avatar answered Oct 08 '22 00:10

SF.