2

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:

keyboard:usb:v*p*
 KEYBOARD_KEY_700e2=leftctrl

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:

keyboard:usb:v*p*
 KEYBOARD_KEY_70039=leftctrl

Running 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:

keyboard:dmi:bvn*:bvr*:bd*:svn*:pn*:pvr*
 KEYBOARD_KEY_3a=leftctrl

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?

Update

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.

  • Just clicking through the Related Questions link on the side here and my belief is many were very related. Specifically look for one about a kernel parameter, another discussing xmodmap, also one from Gilles and one from slm. I would also question what your firmware might or might not actively do to your USB input - boxers often package - and enable by default - certain legacy compatibility behaviors for handling the difference between USB inputs and the older, and much more reliable, parallel inputs. – mikeserv May 7 '14 at 6:22
  • i've been going mad with this! your updated text really solved this mystery! thanks! – pcarvalho Mar 16 '15 at 15:59
  • using the left control as another key wasn't working for me so i remaped it to rightctrl and remaped right control to something else: keyboard:usb:v*p* KEYBOARD_KEY_70039=leftctrl KEYBOARD_KEY_700e0=rightctrl KEYBOARD_KEY_700e4=esc – pcarvalho Mar 17 '15 at 10:37
  • also, for reference, your bug report bugs.freedesktop.org/show_bug.cgi?id=78408 – pcarvalho Mar 17 '15 at 10:39

Your Answer

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

Browse other questions tagged or ask your own question.