How to remap key codes without '/usr/lib/keymap' (which is gone in Saucy, and in Trusty, ...)?
5,527
Keymappings are still done with udev
in trusty (and saucy, I guess), but the mechanism changed.
To remap a key, only one ioctl(EVIOCSKEYCODE)
is necessary, but no simple program doing that exists any more. It is now internal to udev. So do this:
- tell udev the mappings
- create a file
/etc/udev/hwdb.d/keyboard.hwdb
- write only the keyboard identifier in there and mappings you want to change (the format is like in
/lib/udev/hwdb.d/60-keyboard.hwdb
, where I also found those confusing identifiers for my keyboard); for example:keyboard:name:ThinkPad Extra Buttons:dmi:bvn*:bvr*:bd*:svnLENOVO*:pn* KEYBOARD_KEY_00=msdos KEYBOARD_KEY_09=prog3 KEYBOARD_KEY_0a=dashboard
udevadm hwdb --update
- check if you see your updates via
udevadm hwdb --test='keyboard:name:ThinkPad Extra Buttons:dmi:bvn*:bvr*:bd*:svnLENOVO*:pn*'
(change to your keyboard id) udevadm control --reload
is needed even if the man-page says otherwise – I tried it.
- create a file
- trigger their execution (or simply reboot)
- with a running
udevadm monitor --property
you can see the effect of the next step, the--property
option will reveal the remappings - for my keyboard I do a
udevadm trigger --verbose --sysname-match=event6 --action=add
The “add action” is important, because “change” events are ignored in the current keyboard rules. - in your case a
--sysname-match=event3
would do it, but you can play around with it via these three:udevadm trigger --dry-run --verbose
shows you all devices- inspire you fantasy for matcher building with
udevadm info /sys/devices/platform/thinkpad_acpi/input/input12/event6
or whatever your device udevadm trigger --help
will give you hint how to reduce the next trigger dry-run
- with a running
Related videos on Youtube
Author by
Hizoka
Under Kubuntu Linux since 2007. Amateur developer. Solid knowledge of Bash. Good knowledge of Python, PyQt, PHP, SQL. Knowledge in JQuery.
Updated on September 18, 2022Comments
-
Hizoka almost 2 years
X11 doesn’t see keycodes above 255, so how to remap those few keys into the gaps below 255?
/usr/lib/keymap
existed in raring, which worked like this:1. Keys identification:
sudo /lib/udev/keymap input/event3 > scan code: 0xC1021 key code: zoomreset => 100% > scan code: 0xC101F key code: zoomin => zoom - > scan code: 0xC1020 key code: zoomout => zoom + > scan code: 0xC0192 key code: calc => calculator
2. Remap keys:
sudo /lib/udev/keymap input/event3 0xC1021 phone sudo /lib/udev/keymap input/event3 0xC101F sport sudo /lib/udev/keymap input/event3 0xC1020 shop sudo /lib/udev/keymap input/event3 0xC0192 www
It was great, simple and quick...
xmodmap works for keys < 255 like my calculator key (code 148)
sudo evtest /dev/input/event3 Input driver version is 1.0.1 Input device ID: bus 0x3 vendor 0x46d product 0xc517 version 0x110 Input device name: "Logitech USB Receiver" ... Testing ... (interrupt to exit) > Event: time 1381940761.592647, type 1 (EV_KEY), code 140 (KEY_CALC), value 1 => calculator > Event: time 1381940790.224658, type 1 (EV_KEY), code 420 (KEY_ZOOMRESET), value 1 => 100% > Event: time 1381940810.928667, type 1 (EV_KEY), code 419 (KEY_ZOOMOUT), value 1 => Zoom - > Event: time 1381940836.216678, type 1 (EV_KEY), code 418 (KEY_ZOOMIN), value 1 => Zoom +
**EDIT : I have found the solution in this ubuntuforum post.
-
Robert Siemer about 10 yearsYour “solution” uses an external program call “evrouter” which is not necessary – not a real solution, but a workaround.
-
Robert Siemer about 10 years
xmodmap
comes to late in the food chain, as X11 doesn’t see keycodes above 255. – Btw, I don’t usexmodmap
as it knows nothing about XKB. I fiddle with the xkb config files and runsetxkbmap ...
for X related keyboard configuration (which this problem is not really).
-
-
Karthik T almost 9 yearsWhat about step # 1 of the OP's Info?
-
Robert Siemer almost 9 years@KarthikT, I never used that
keymap
tool. As explained in60-keyboard.hwdb
you can useevtest
to get scan codes. -
Karthik T almost 9 yearsI see, is that as close to the metal as it gets? I am trying to do this in superuser.com/questions/970279/using-a-gaming-keyboard-on-osx/970338 and
evtest
returns the same code for all the keyboard modifiers, so cant exactly remap just one..