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?
-
Clarify - on the actual device, with keyboard plugged in? If that's the case, depends on the kernel if it has USB-OTG support... what Android version? – t0mm13b Jan 16 '13 at 16:17
-
Typically Android devices will not be able to operate in USB host mode and USB device mode at the same time AFAIK. Might be possible on some devices (perhaps with a custom ROM), but I wouldn't count on it to work on the vast majority of phones out there. – Michael Jan 16 '13 at 18:07
-
USB host support is available officially and is available on both devices I tried. – Audrius Meškauskas Jan 16 '13 at 19:02
-
possible duplicate of [Unable to use keyboard in Android emulator](http://stackoverflow.com/questions/11316818/unable-to-use-keyboard-in-android-emulator) – Yehuda Katz Jan 16 '13 at 19:02
-
I want to keep keyboard connected to computer and do input on android device from that same keyboard. May be like in emulator I can use keyboard, I want to use my computer keyboard while debugging a app on actual device – NinjaCoder Jan 21 '13 at 22:46
5 Answers
Share KM is a free app that lets you use your PC's keyboard and mouse to control your Android. Connection can be made over USB, WiFi, or Bluetooth.
It works a lot like adding an additional monitor to your computer – move your mouse to the edge of your screen and the cursor moves to the Android.

- 139,160
- 33
- 216
- 263
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

- 3
- 3
It sounds like you want to use your PC's keyboard via some software on the PC rather than use a separate USB keyboard connected to the Android device.
This actually is possible, but the details are device specific. You would need to send key events via adb, but you'd need to determine the implementation-specific translation of characters to event codes, and even the event channel number. There are likely open source projects out there for doing this, and you'd be better off starting with one of those than trying to develop it from scratch.
As for using a separate USB keyboard, as mentioned in comments this is a possibility on some more recent devices (typically you need an adapter cable with the ID pin grounded) but introduces the issue of not being able to use USB for ADB as well as a keyboard at the same time. One possible workaround would be to put ADB into TCP/wireless mode, unplug the computer and plug in the keyboard. A simpler approach could be to use a bluetooth keyboard.
Note that either the USB or bluetooth keyboard, and likely also the key event method, will cause the on-screen keyboard to pop up. People trying to use devices with external keyboards find this annoying and tend to install zero-height on screen keyboards; however, if you are testing what an actual user will do, then having the keyboard pop up will give a more realistic impression of the end-user experience (though of course the amount of screen real estate left after the keyboard varies from device to device).

- 39,853
- 6
- 84
- 117
-
I want to keep keyboard connected to my computer. I don't want to connect it to device physically. – NinjaCoder Jan 21 '13 at 22:46
-
Yes, that is what I described first with injecting key events via adb. – Chris Stratton Jan 22 '13 at 00:58
Plug your keyboard directly into Android USB OTG port and it will work. Most of recent Android devices do support USB host mode apart very few models that have this feature intentionally removed (Google). There is also a good our guestion about this.
With my Google Galaxy Nexus and Lenovo tablet, even mouse works (mouse pointer appears). You probably can use USB switch that allows to share the keyboard between two computers. Mind also that you need USB OTG and not USB device converter (there are some USB converters that fit into micro USB OTG port nicely but are for USB devices only).
Of course, ADB cannot use the USB port if it is already taken by the keyboard. Hence you need to use wireless for ADB.
This proposal does not match fully your initial idea but seems matching the goal you are aiming to achieve (debug Android app directly on device using your keyboard).

- 1
- 1

- 20,936
- 12
- 75
- 93
As of Juli 2023 there is no need to install any 3rd party app on the smartphone. Tested with a desktop computer running XUbuntu 22, installed Android Studio 2022.2.1 Patch 2 and a smartphone running Android 11.0:
- Install Android Studio on desktop computer, see https://developer.android.com/studio/install
- Enable Developer mode in Smartphone, see https://developer.android.com/studio/debug/dev-options
- Connect Smartphone and desktop computer via USB cable
- Enable Settings->Connected devices->USB->File transfer on the smartphone
- Start Android Studio on desktop computer
- In Studio: Top Menu Bar->View->Tool Windows->Device Manager 7 In Device Manager Window: click the circle to rescan devices if smartphone is not listed (in "Physical" tab)
- The Smartphone should show pop-up window asking if to allow Debugging. Touch "Allow"
- In Device Manager Window: Click "Physical" tab, the connected Smartphone should be listed.
- Top Menu Bar->File->Settings->Tools->Device Mirroring->click "Enable clipboard sharing", then "OK"
- Top Menu Bar->View->Tool Windows->Running Devices The Smartphone should appear there

- 2,415
- 18
- 10