Linux – How to map extra keys in linux

keyboardlinuxxmodmapxorg

I'm running archlinux on my thinkpad x1 carbon 5th gen which has some extra keys. These keys currently do nothing and I'd like to remap them.

Firstly, I tried getting their keycodes via xev but they weren't being detected so I found out their keycodes via evtest.

Here are the results:

Event: time 1519668920.038747, type 4 (EV_MSC), code 4 (MSC_SCAN), value 45
Event: time 1519668920.038747, type 1 (EV_KEY), code 364 (KEY_FAVORITES), value 1
Event: time 1519668920.038747, -------------- SYN_REPORT ------------
Event: time 1519668920.038836, type 4 (EV_MSC), code 4 (MSC_SCAN), value 45
Event: time 1519668920.038836, type 1 (EV_KEY), code 364 (KEY_FAVORITES), value 0
Event: time 1519668920.038836, -------------- SYN_REPORT ------------
Event: time 1519668923.198764, type 4 (EV_MSC), code 4 (MSC_SCAN), value 49
Event: time 1519668923.198764, type 1 (EV_KEY), code 374 (KEY_KEYBOARD), value 1
Event: time 1519668923.198764, -------------- SYN_REPORT ------------
Event: time 1519668923.198883, type 4 (EV_MSC), code 4 (MSC_SCAN), value 49
Event: time 1519668923.198883, type 1 (EV_KEY), code 374 (KEY_KEYBOARD), value 0
Event: time 1519668923.198883, -------------- SYN_REPORT ------------

So tried mapping them to regular keys using xmodmap. For ex.

keycode 374 = F13
or

keycode 374 = XF86LaunchB

but was unsuccessful. How do I go about this? I have also tried to set the scan codes to keycodes via
setkeycoder 45 255 but to no avail.

Best Answer

The only thing that comes to mind is Gianni Ceccarelli's patched xf86-input-evdev which adds a new xorg configuration option called event_key_remap (details on his page).
I can't test it with an actual keyboard - my laptop keyboard doesn't produce keycodes above 255 - but I've successfully used it in the past to remap buttons on remote controls for mythTV setups.

Related Question