Background: I got the Microsoft Natural Ergonomic Keyboard 4000 and several keys are not working at all under Ubuntu such as the F1-F10 keys. I have Ubuntu 14.04.2 LTS running on my machine.

My solution: I created the file /etc/udev/hwdb.d/61-keyboard-local.hwdb and set up come custom rules:


I got the hex code through xev. For instance, for the key which should be the F1 key, xev returns

KeyRelease event, serial 37, synthetic NO, window 0x4400001,
    root 0xa2, subw 0x0, time 1746028, (12,-12), root:(61,40),
    state 0x10, keycode 146 (keysym 0xff6a, Help), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

After changing the file, I ran udevadm hwdb --update and udevadm trigger and, additionally, restarted my laptop.

Issue: The corresponding functionality is not assigned to the respective keys.

2 Answers 2

  • That one from xev is the key symbol keysym, here the idea:

    /keyboard/ → scancode → /input driver/ → keycode → /X server XKB/ → keysym

    man xev says: xev - print contents of X events

  • So, what you are looking for is the early hardware data from keyboard which is the scancode. It can be found using evtest

    man evtest evtest - Input device event monitor and query tool

    1. Install it

      sudo apt-get install evtest
    2. Run

      sudo evtest


      Event: time 1435906588.943349, type 4 (EV_MSC), code 4 (MSC_SCAN), value 3b
      Event: time 1435906588.943349, type 1 (EV_KEY), code 59 (KEY_F1), value 1

      Scancode is 3b


I got an external keyboard working in Ubuntu 20.04 using the information from https://www.foell.org/justin/remapping-keyboard-keys-in-ubuntu-with-udev-evdev/

  1. use sudo evtest to find the info about your keyboard, like:
Input driver version is 1.0.1
Input device ID: bus 0x5 vendor 0x5ac product 0x24f version 0x11b
Input device name: "Keychron K6 Keyboard"
  1. use sudo evemu-describe to find the properties of the keyboard, including the leading zeros. In the output you can find something like:
# Properties:
N: Keychron K6 Keyboard
I: 0005 05ac 024f 011b
  1. create the .hwdb file like you did but include all the leading 000, and put any hexadecimal symbols in uppercase like:
# Input device ID: bus 0x5 vendor 0x5ac product 0x24f version 0x11b
# evdev:input:b<bus_id>v<vendor_id>p<product_id>e<version_id>-<modalias>

  1. you don't have to reboot your system, just do:
$ sudo systemd-hwdb update
$ sudo udevadm trigger
  1. you can check if your keyboard has been mapped correctly using $ udevadm info /dev/input/event20 (replace event20 with the event for your keyboard)
  • Please be a little careful with posting exact copy and paste answers throughout Ask Ubuntu. Answers should be carefully tailored to exactly fit the question being asked.
    – andrew.46
    Jun 12 at 1:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.