Project Url: senzhk/ADBKeyBoard
Introduction: Android Virtual Keyboard Input via ADB
More: Author   ReportBugs   

Android Virtual Keyboard Input via ADB

ADBKeyBoard is a virtual keyboard that receives commands from system broadcast intents, which you can send text input using adb.

There is a shell command 'input', which can help you send text input to the Android system.

usage: input [text|keyevent]
  input text 
  input keyevent 

But you cannot send unicode characters using this command, as it is not designed to use it this way.
Reference :

adb shell input text '你好嗎' 
is not going to work.

ADBKeyboard will help in these cases, especially in device automation and testings.

Build and install APK

With one device or emulator connected, use these simple steps to install the keyboard:

  • Get source: git clone
  • Go into project dir cd ADBKeyBoard
  • Set Android SDK location: export ANDROID_HOME=$HOME/Android/Sdk or edit file
  • Build and install: ./gradlew installDebug

How to Use

  • Enable 'ADBKeyBoard' in the Language&Input Settings.
  • Set it as Default Keyboard OR Select it as the current input method of certain EditText view.
  • Sending Broadcast intent via Adb or your Android Services/Apps.

Usage Example:

1. Sending text input
adb shell am broadcast -a ADB_INPUT_TEXT --es msg '你好嗎? Hello?'

* This may not work for Oreo/P, am/adb command seems not accept utf-8 text string anymore

1.1 Sending text input (base64) if (1) is not working.

* For Mac/Linux, you can use the latest base64 input type with base64 command line tool:
adb shell am broadcast -a ADB_INPUT_B64 --es msg `echo '你好嗎? Hello?' | base64`

* For Windows, please try this script (provided by ssddi456):

2. Sending keyevent code  (67 = KEYCODE_DEL)
adb shell am broadcast -a ADB_INPUT_CODE --ei code 67

3. Sending editor action (2 = IME_ACTION_GO)
adb shell am broadcast -a ADB_EDITOR_CODE --ei code 2

4. Sending unicode characters
To send 😸 Cat
adb shell am broadcast -a ADB_INPUT_CHARS --eia chars '128568,32,67,97,116'

Switch to ADBKeyBoard from adb (by robertio) :

adb shell ime set   

Switch back to original virtual keyboard: (swype in my case...)

adb shell ime set com.nuance.swype.dtc/com.nuance.swype.input.IME  

Check your available virtual keyboards:

adb shell ime list -a  

You can try the apk with my debug build:

KeyEvent Code Ref:

Editor Action Code Ref:

About Me
Google+: Trinea trinea
GitHub: Trinea