I'm trying to remap LCtrl and CapsLock on my Microsoft Wired Keyboard 600 with HWDB but for whatever reason the system does not see the changes that I make.

This is how my hwdb rule looks like:


The vendor and the model codes come from lsusb and were reconfirmed in /sys/devices/pci0000:00/*

After copying the config file to /etc/udev/hwdb.d, running systemd-hwdb update and issuing udevadm trigger no changes in the keyboard config are present.

I've also tried:

  • Rebooting — didn't help.
  • Specifying the bus explicitly as 0003 — didn't help.
  • Confirming with evtest that the key codes I'm using are correct for my keyboard — yep, those are the correct keycodes.
  • Confirming the applied rules are listed in sudo udevadm info /sys/class/input/eventX — yes, the new rules are listed, which should mean they were applied successfully? Yet the keys behave the same way they did before.
E: KEYBOARD_KEY_1d=capslock
E: KEYBOARD_KEY_3a=leftctrl

When I use evdev:atkbd:dmi:* as the device identifier instead the change is correctly applied to my laptop keyboard so I know the rule and the process I'm using to remap the keys should be correct, it's got to be an issue with the wrong identifier (though I've quintuple checked it).

Any help will be appreciated.


Turns out I was specifying the wrong kind of scancodes. When getting key codes with evtest, you get the following output (assuming the left shift button is pressed):

Event: time xxx.xxx, type 4 (EV_MSC), code 4 (MSC_SCAN), value 700e1
Event: time xxx.xxx, type 1 (EV_KEY), code 42 (KEY_LEFTSHIFT), value 0

The code I was using was the standard key code (42). But as it turns out, this is wrong.

The actual code you're supposed to specify in the hwdb file is the scancode from the MSC_SCAN line (in this example, it is 700e1, preceded by the word value)

This works:


Reference: Rebinding Keyboard Keys @ altlinux.org (it's in Russian but it is the most comprehensive article I've found on the web that stresses that nuance)

I vividly remember using basic scancodes on my laptops and them working. I'm not quite sure why that is the case. Perhaps they happen to match the EV_MSC scancodes on some types of keyboards.

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.