Last active
January 24, 2021 20:52
-
-
Save chp-io/f6b23248712a7884dddf3e766a8330dc to your computer and use it in GitHub Desktop.
Key remapping on Windows and Linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/udev/hwdb.d/99-keyremap.hwdb | |
# Remap a key or swap keys for a keyboard using udev | |
# To remap a key, replace the bus, vendor, product, scancode, keycode in: | |
#evdev:input:b<bus>v<vendor>p<product>* | |
# KEYBOARD_KEY_<scancode>=<keycode> | |
# Apply your changes to this file with: | |
# #> systemd-hwdb update && udevadm trigger | |
# To find device bus, vendor, product: | |
# | |
# $> cat /proc/bus/input/devices | |
#I: Bus=0011 Vendor=0001 Product=0001 Version=ab54 | |
#N: Name="AT Translated Set 2 keyboard" | |
#H: Handlers=sysrq kbd event3 leds | |
# The previous command allows us to find the scancode and keycode. | |
# The handlers line of the previous command gives us `event3` from which we can | |
# | |
# #> evtest /dev/input/event3 | |
#Event: time 1611518997.616241, type 4 (EV_MSC), code 4 (MSC_SCAN), value 3a | |
#Event: time 1611518997.616241, type 1 (EV_KEY), code 58 (KEY_CAPSLOCK), value 1 | |
#Event: time 1611518997.616241, -------------- SYN_REPORT ------------ | |
#Event: time 1611518997.616793, type 17 (EV_LED), code 1 (LED_CAPSL), value 1 | |
#Event: time 1611518997.616793, -------------- SYN_REPORT ------------ | |
#Event: time 1611518997.656002, type 4 (EV_MSC), code 4 (MSC_SCAN), value 3a | |
#Event: time 1611518997.656002, type 1 (EV_KEY), code 58 (KEY_CAPSLOCK), value 0 | |
#Event: time 1611518997.656002, -------------- SYN_REPORT ------------ | |
#Event: time 1611519000.174220, type 4 (EV_MSC), code 4 (MSC_SCAN), value 1d | |
#Event: time 1611519000.174220, type 1 (EV_KEY), code 29 (KEY_LEFTCTRL), value 1 | |
#Event: time 1611519000.174220, -------------- SYN_REPORT ------------ | |
#Event: time 1611519000.213325, type 4 (EV_MSC), code 4 (MSC_SCAN), value 1d | |
#Event: time 1611519000.213325, type 1 (EV_KEY), code 29 (KEY_LEFTCTRL), value 0 | |
#Event: time 1611519000.213325, -------------- SYN_REPORT ------------ | |
# | |
# The line with MSC_SCAN value 3a gives us the scancode, 3a | |
# The line directly bellow gives its keycode in lower case from KEY_*, capslock | |
# Swap capslock with ctrl: | |
evdev:input:b0011v0001p0001* | |
KEYBOARD_KEY_3a=leftctrl | |
KEYBOARD_KEY_1d=capslock | |
# To debug: | |
# #> udevadm test $(udevadm info --query=path --name=/dev/input/event3) 2>&1 | less |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Windows Registry Editor Version 5.00 | |
; DIK Keycodes can be found here: | |
; https://github.com/glfw/glfw/blob/d203ccbf5ec4442809a0696a704b2b3a7041559d/deps/mingw/dinput.h#L509 | |
; The hex data is in five groups of four bytes: | |
; 00,00,00,00,\ header version (always 00000000) | |
; 00,00,00,00,\ header flags (always 00000000) | |
; 04,00,00,00,\ # of entries (3 in this case) plus a NULL terminator line. | |
; Entries are in 2-byte pairs: Key code to send & keyboard key to send it. | |
; Each entry is in LSB, MSB order. | |
; 1d,00,3a,00,\ Send LEFT CTRL (0x001d) code when user presses the CAPS LOCK key (0x003a) | |
; 38,00,1d,00,\ Send LEFT ALT (0x0038) code when user presses the LEFT CTRL key (0x001d) | |
; 3a,00,38,00,\ Send CAPS LOCK (0x003a) code when user presses the LEFT ALT key (0x0038) | |
; 00,00,00,00 NULL terminator | |
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout] | |
"Scancode Map"=hex:00,00,00,00,\ | |
00,00,00,00,\ | |
03,00,00,00,\ | |
1d,00,3a,00,\ | |
3a,00,1d,00,\ | |
00,00,00,00 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment