Using an hwdb file,
/etc/udev/hwdb.d/99-keyboard.hwdb, I can remap the left Alt key on my USB keyboard as the Ctrl key:
This also works when I try to remap the left Shift key as the Ctrl key.
But when trying to remap Caps Lock as the Ctrl key, it does not work:
evtest indicates that it should be working:
Event: time 1399438713.757082, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70039 Event: time 1399438713.757082, type 1 (EV_KEY), code 29 (KEY_LEFTCTRL), value 1 Event: time 1399438713.757082, -------------- SYN_REPORT ------------ Event: time 1399438713.885078, type 4 (EV_MSC), code 4 (MSC_SCAN), value 700e0 Event: time 1399438713.885078, type 1 (EV_KEY), code 29 (KEY_LEFTCTRL), value 0 Event: time 1399438713.885078, -------------- SYN_REPORT ------------
It also does not work on other non-modifier keys I tried, such as Z.
I have also tried to map Caps Lock to the left Ctrl key on a non-USB keyboard, as such:
This works perfectly. I tried udev versions 208 and 212 with a few different USB and non-USB keyboards, on Fedora 20 and on Arch Linux.
How can I remap a non-modifier key such as Caps Lock to a modifier key such as Ctrl on a USB keyboard using udev?
If the left Ctrl is itself remapped to another key, then the remapped key starts to work as the left Ctrl key. For example:
keyboard:usb:v*p* KEYBOARD_KEY_700e0=grave KEYBOARD_KEY_70035=esc KEYBOARD_KEY_70039=leftctrl KEYBOARD_KEY_70029=capslock
This behaviour is different from a non-USB keyboard, where both the remapped key and the original key may remain as a modifier.