Adding keymap to Android

I am using a keypad with just 4 keys (HOME, BACK, MENU and ENTER) on my iMX51 board, but it is not correctly mapped.

I started to searching for a solution and found this tutorial:

The keypad keycode wasn’t following the function defined on qwert.kl because it uses other keymap file (/system/usr/keylayout/mxckpd.kl). Now just modifying this file or the keypad keycode in the kernel driver to reflect the same function solved the issue.

20 thoughts on “Adding keymap to Android

  1. Hi,
    In my board two key pads are there one is usb and another is matrix keypad.
    when i press the keys from the usb keyboard i am able to see them on the display which is on the board.
    But when i press the keys from matrix keypad i am unable to see them.
    But i am sure my driver is generating the events.
    Anroid is still not ported.

    Plz help me

  2. Hi Lakshmi,

    Are you testing it on Linux or inside Android?

    You can test keyboard events using:

    $ getevent /dev/input/event0

    Just replace event0 by event number of your matrix keypad.

    Using these keys code you can create your keyboard.kl.

    Best Regards,


  3. Hi Lakshmi,

    I think your matrix keypad doesn’t have a working driver in the Linux kernel.

    You can check it executing:
    $ cat /proc/bus/input/devices

    Your keypad name should appear in the listing. For example in may Freescale board I can see the Name: mxc_keypad.

    I hope it help you.

    Best Regards,


    1. Mine is also mxxc_keypad. Driver is there for that. Its generating the keycodes. I can see them , but the problem is its not converting the keycodes to characters..

  4. Is /drivers/char/keyboard.c is the input driver for the mxc keypad??
    how to link my input driver with the event driver. usb keyboad is going to the /drivers/char/keyboard.c . BUt my mxc keypad driver is not….

  5. what is the difference between the keypad driver and the keyboard driver? Is input event driver exists for the both. If yes what is the event driver for the mx51 mxc_kbd driver? I hope event driver will convert the keycodes to the character. so in my case usb keyboard is using the driver/char/keyboard.c driver as event driver. I dont know about the mxc_kbd.c.
    Plz help me

  6. Hi Lakshmi,

    You can modify the keymapping variable existent in the file: arch/arm/mach-mx5/mx51_babbage.c.

    If you still getting issues I suggest you to open a Service Request in Freescale website.

    Best Regards,


  7. Hmm. But my doubt is is it possible to see the key press from the matrix keypad directly on the virtual console?? without running any evtest.
    Waiting for your reply

    1. yes, if you discover the keypad event# at /proc/bus/input/devices you could see if it is generating events this way:

      $ cat /dev/input/event3

      Where event3 is the event # of your keypad.

      When you press any key it will generate codified events (trash characters), but this way you could to know it is working or not.

      Best Regards,


  8. NO not by opening the cat /dev/input/event0.
    i mean when we open minicom if we press a key from the keyboard we can see them on the minicom right.
    suppose i want to type cat /dev/input/event0 from the mxc_keypad (The command and the output also should be shown on the VIrtual console). Is it possible?? Can we type the commands on the virtual console by using the mxc_kpd??

  9. HI,
    I have a query regardign keypad. When we press a caps lock key how the driver will show the keys in Capital Letters. The key code for the lower case and upper case are same so how it will differentiate the two??

  10. Hi Lakshmi,

    When you press a key in the keyboard it sends a keycode to computer and when you release it sends another keycode. When you press the Caps Lock it don’t modify these keycodes. The Caps Lock needs to be handled by the Operating System. You can verify it in your Linux computer. Enter on text terminal (CTRL+ALT+F2) and execute the command “showkey”, it will show the keycodes returned when you press any key.
    Since Android uses Linux kernel then it is using the Linux Input Subsystem that works this same way.

  11. Hi,
    As i told earlier. I have one usb keyboard and one matrix keypad on my board. Matrix keypad is loaded statically and usb keyboard is loaded dynamically.
    The problem i am facing is after loading both the modules when i press a key from the usb keyboard its displaying them in the Capital letters(Caps lock key is not pressed) . If i press a key from the keypad its showing in the lower case letter (As expected).

    When i set the keybit and the evbit in the keypad matrix before registering it with the input layer i am seeing the above behaiour. If i wont set the evbit and keybit in the keypad matrix driver code Usb keyboard is working fine but the not seeing any keys which or pressed from the matrix keypad on the console.

    Please help me to solve this

  12. Here I tried explained in biref..
    1. Compile the keypad also as a module.
    2. Insert the usb module
    3. Press the key from the usb keyboard
    -> Keyboard is working fine
    4. Then insert the keypad module
    6. Press the key from the keypad
    ->In this scenario both the keypad and keyboard are working fine : Expected

    1. Insert the usb module
    2. First press any key “from the keypad”
    3. Then press a key from the keyboard
    ->In this scenario also both the keyboard and keypad are working fine : Expected

    Case3: (Problematic) :
    1. Insert the usb module
    2. Press a key “from the usb keyboard”
    In this scenario by default, caps lock functionality is working which is not expected!!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s