336

I've upgraded the SDK tools to revision 20 (from 18) and since the upgrade, the emulator doesn't seem to accept input from laptop's keyboard. But only using the emulator's own 'soft' keyboard (that appears when an input field is focused).

I've tried reinstalling the SDK tools (and the whole SDK for that matter), uninstalled and reinstalled Eclipse Android plugins, re-created emulator devices. But none of that seem to help and its driving me mad. Its hopeless to key-in using a laptop's trackpad.

Has anyone encountered this problem?

Sergey Glotov
  • 20,200
  • 11
  • 84
  • 98
epsilonpsi
  • 3,753
  • 3
  • 17
  • 16
  • A side effect of this seems to be that the search button in the emulator doesn't seem to work either. Thankfully, the same fix for the keyboard fixes the search button as well. – bmaupin Jun 29 '12 at 18:19
  • I have also found that for some apps I had to go to `Extended Controls` -> `Send keyboard shortcuts to` -> `s/Emulator controls (default)/Virtual device/` – snapfractalpop Mar 30 '19 at 04:40

13 Answers13

480

Update

As of SDK rev 21 the Android Virtual Device Manager has an improved UI which resolves this issue. I have highlighted some of the more important configuration settings below:

enter image description here

If you notice that the soft (screen-based) main keys Back, Home, etc. are missing from your emulator you can set hw.mainKeys=no to enable them.

enter image description here

Original answer

Even though the developer documentation says keyboard support is enabled by default it doesn't seem to be that way in SDK rev 20. I explicitly enabled keyboard support in my emulator's config.ini file and that worked!

Add: hw.keyboard=yes

To: ~/.android/avd/<emulator-device-name>.avd/config.ini

Similarly, add hw.dPad=yes if you wish to use the arrow-keys to navigate the application list.

Reference: http://developer.android.com/tools/devices/managing-avds-cmdline.html#hardwareopts

On Mac OS and Linux you can edit all of your emulator configurations with one Terminal command:

for f in ~/.android/avd/*.avd/config.ini; do echo 'hw.keyboard=yes' >> "$f"; done


On a related note, if your tablet emulator is missing the BACK/HOME buttons, try selecting WXGA800 as the Built-in skin in the AVD editor: enter image description here

Or by manually setting the skin in config.ini:

skin.name=WXGA800
skin.path=platforms/android-16/skins/WXGA800

(example is for API 16)

Gili
  • 86,244
  • 97
  • 390
  • 689
James Wald
  • 13,626
  • 5
  • 52
  • 63
  • 1
    As the other answers mentioned you can use the AVD Manager tool as well but I have experienced bugs that prevent it from saving config changes. – James Wald Jul 02 '12 at 20:02
  • Is there any global setting that will affect all of my existing avd? I don't want to change about 20 existing avd. – Hoang Tran Jul 13 '12 at 03:34
  • @HoangTran There is no global configuration, however, if you are using Mac OS you can use the Terminal command that I added to the answer to edit all existing AVDs at once. – James Wald Jul 16 '12 at 22:20
  • Sadly this solution didn't work for me. After running the command, the keyboard still doesn't work in my avd's. – Justin Aug 31 '12 at 14:18
  • @Justin do you see hw.keyboard=yes in your avd files? – James Wald Sep 05 '12 at 20:11
  • Well this fixed the problem, but now the soft keyboard doesnt pop up anymore. – Urban Sep 29 '12 at 13:14
  • Yeah, that happens here too. I haven't determined any way to get both working at the same time. In addition to this, on tablet sized devices the device back and home buttons are also missing. – James Wald Sep 29 '12 at 14:43
  • 1
    Editing the config file worked for me, but oddly I don't see the UI shown in the picture, despite having version 21 of the SDK. – offby1 Dec 10 '12 at 03:04
  • 1
    It happened again. I had a working emulator hardware keyboard, then upgraded from SDK 25.0.3 to 26.0.x and the hardware keypoard stopped working. The same answer fixes the problem though. But, I wish I knew why/how the emulator setting was changed. – Les Jul 21 '17 at 18:27
  • In Andoird-Studio: Tools => Android => AVD-Manager=> Pencil Icon => "Advanced Settings" – Stefan Steiger Oct 10 '17 at 12:24
  • I literally already have that and it's still not working... Any help? – busuu May 09 '18 at 09:57
  • 1
    you can open the avd manager tool via `android avd` at a commandline. http://www.androiddocs.com/tools/devices/managing-avds.html – Harry Moreno Jun 06 '18 at 21:22
113

Confirmed. I had the same problem after upgrading to Tools version 20. I had to Edit the AVD to add an option as follows:

  1. From Eclipse, Go to AVD Mananger.
  2. Select the particular AVD and click on Edit
  3. Go to the Hardware section, click on New.
  4. Select the Property Name : Keyboard Support
  5. By default, it is added with a value of 'no'. Just click on the value column and change it to 'yes'.
  6. Click on Edit AVD again.

This will add a property hw.keyboard=yes in config.ini file for the AVD.

You also have to set hw.mainKeys = yes

Romin
  • 8,708
  • 2
  • 24
  • 28
  • 19
    Make sure the value column loses focus before clicking Edit AVD or the change to 'yes' will not be saved! – Nuthatch Jul 02 '12 at 15:10
  • 1
    Hi, I followed the above instructions, but still can't insert any text using my PC key board. When I double click on the AVD listed under the AVD Manager, I find that the edit is successful as it indicates hw.keyboard:yes. Am I missing something??? – JibW Jul 06 '12 at 12:17
  • 3
    I suggest the following : Delete the AVD and create a completely fresh AVD with the Keyboard support. – Romin Jul 06 '12 at 12:47
61

In Android Studio, open AVD Manager (Tools > Android > AVD Manager). Tap the Edit button of the emulator: enter image description here

Select "Show Advanced Settings" enter image description here

Check "Enable keyboard input" enter image description here

Click Finish and start the emulator to enjoy the keyboard input.

Hong
  • 17,643
  • 21
  • 81
  • 142
  • Worked for me after enablinh keyboard input setting but wondering how did it stopped working by itself in first place. – Justcurious Jul 20 '17 at 17:41
  • 3
    It is so frustrating that this checkbox unchecks itself after every emulator update :( – Misha Akopov Aug 12 '17 at 07:11
  • 2
    In my case, keyboard was enabled, but did not work in the emulator. The fix is to disable keyboard, start emulator, terminate emulator, enable keyboard. – beroal Dec 19 '18 at 13:53
15

Look in AVD Manager, select the AVD and click in Edit. In Hardware section: click in "New" and search for "Keyboard support" and add with OK button and set the value to "yes" and save changes with "Edit AVD"

Joel Pelaez
  • 311
  • 1
  • 3
  • weird thing is, when i set this value to yes, it forces the value back to no, anyway will test with a new Device again – epsilonpsi Jun 29 '12 at 08:36
  • I preferred this answer. Using the AVD manager is a more memorable solution than changing the config.ini file. – Seth Jul 25 '12 at 16:13
10

Google wanted to give some more headache to the developers.

So, what you have to do now is edit your AVD and add "Keyboard Support" for it in the Hardware section and change the value to "Yes"

Vincy
  • 1,078
  • 1
  • 9
  • 16
  • 1
    Didn't work for me, the avd keyboard support value of "yes" doesn't stay saved, it keeps reverting back to "no". – Justin Aug 31 '12 at 14:18
  • Actually Google wanted to improve things. Most devices now don't have hardware keyboards, so the default should be none/disabled. Yeah, it's easier to work with the emulator with one, but that's not mirroring real world conditions. The correct way is to make devs specifically enable it. – Charlie Collins Nov 12 '12 at 15:36
8

Add the following line hw.keyboard=yes to your AVD config file ~/.android/avd/<avd_folder>/config.ini

Nerower
  • 193
  • 12
Amit Yaron
  • 574
  • 1
  • 5
  • 6
3

Restarting the emulator helps sometimes when typing is unavailable - despite keyboard input being enabled for your Android Virtual Device.

starbeamrainbowlabs
  • 5,692
  • 8
  • 42
  • 73
Zon
  • 18,610
  • 7
  • 91
  • 99
2

Just in case somebody finds it usefull.

I had a problem with the KEYCODE_DPAD_UP it belongs to the trackBall. to solve this change your avdfolder/config.ini hw.trackBall=yes and push DEL or F6

PbxMan
  • 7,525
  • 1
  • 36
  • 40
1

Here is some workaround that actually worked for me, it is the same solution as in the most popular answer - just add hw.keyboard=yes to config.ini but since this didn't work for me I additionally

  1. renamed config.ini (any name will do) to something like consssssfig.ini
  2. restarted emulator (obviously it didn't start)
  3. renamed config.ini back again
  4. (I am not sure if relevant) I added this new parameter (hw.keyboard=yes) at the beggining of config.ini file
Witold
  • 88
  • 7
1

Sometimes computer keyboard stops working on android emulator. Today I've noticed, that after pushing this button (that I marked with red arrow), keyboard starts working again (seems to be some issues with emulator window focus)

screenshot

wilddev
  • 1,904
  • 2
  • 27
  • 45
0

Look for the hidden .android folder in your user home folder. You might rename or delete this folder, recreate your AVD, and restart the emulator. It could be there is a .ini file in that folder that has that setting munged.

Eric Cloninger
  • 2,260
  • 2
  • 21
  • 26
0

Recreating an AVD with the Hardware Keyboard + setting the boolean to true was the only solution that worked for me; the other two main solutions (terminal or editing an existing AVD via GUI) both resulted in software/emulator crashes on my Mac. Making a new AVD resulted in the keyboard working just fine.

Davek804
  • 2,804
  • 4
  • 26
  • 55
0

I have used an emulator for API Level 23, which does not take keyboard input for installed apk. So I have created new emulator for API Level 29, and then it works. Following is the step to install new emulator.

  1. Open "Android Virtual Device Manager"
  2. Create new Virtual Device.
  3. When you select a system image, please choose and download the last version(API Level29) on "Virtual Device Configuration" window
persec10000
  • 820
  • 2
  • 10
  • 17