Search code examples
androidandroid-emulator

In Android USB debugging mode, can I make my computer keyboard as input device to my mobile handset while USB debugging?


I like USB debugging on Android as it is faster than Emulator. I know I can use my keyboard in emulator but while debugging I want to use my computer keyboard (plugged to computer) instead of devices keyboard for making my input more faster. Is that possible?


Solution

  • I found a possibility via "adb tools". Connect your phone to the computer via usb cable and start adb at the computer terminal (e.g. Ubuntu)

    adb shell input keyboard text Hello    
    

    or

    adb shell input [<source>] <command> [<arg>...]    
    

    This will give you the possibility to send text/keystrokes via computer/laptop keyboard to your smartphone.

    Note: your input will be sent through two shells (computer and android device), so you'd have to "double escape" even spaces. To avoid that, you may e.g. type

    adb shell
    input keyboard 'any text you like, including shell-sensitive characters'
    

    the second line is input on your android device in adb shell

    Tested on Ubuntu 14.04 LTS and Samsung Galaxy S3 with CyanogenMod. Confirmed on Ubuntu 18.04 LTS and Moto G2 with Lineage OS