A macropad (HID 5131:2019) was sending KEY_2 (scancode 7001f
) when a button was pressed, but needed to send F13 instead.
Use udev's hwdb (hardware database) to remap the scancode to F13.
-
Identify the device and scancode
# Find your device cat /proc/bus/input/devices | grep -A 5 "5131:2019" # Monitor keypresses to get scancode sudo evtest /dev/input/eventX # Replace X with your device event number
-
Create hwdb rule Create
/etc/udev/hwdb.d/90-macropad.hwdb
:# Remap macropad button 2 to F13 # Device: HID 5131:2019 evdev:input:b0003v5131p2019* KEYBOARD_KEY_7001f=f13
Important: The line with
KEYBOARD_KEY_7001f=f13
must start with a single space, not a tab. -
Apply the changes
# Copy the file to the correct location sudo cp 90-macropad.hwdb /etc/udev/hwdb.d/ # Update the hardware database sudo systemd-hwdb update # Trigger udev to reload sudo udevadm trigger
-
Test
- Unplug and replug the macropad, or reboot
- Press the button - it should now send F13
evdev:input:b<bus_id>v<vendor_id>p<product_id>*
KEYBOARD_KEY_<scancode>=<keyname>
b0003
= USB bus (0003)v5131
= Vendor ID (5131)p2019
= Product ID (2019)7001f
= Scancode in hexf13
= Target key name (see/usr/include/linux/input-event-codes.h
for all key names)
- systemd hwdb documentation
- Available key names:
/usr/include/linux/input-event-codes.h
- Test with:
evtest
orxev
(for X11)