We look at how we can remap keys on your keyboard in Linux with Xorg, using xmodmap. In my example, I'll remap the Context Menu key to Right Super, since this key is missing on some keyboards, being replaced by a Function key for multimedia functions.
1. Determine the keycode of the key you want to remap using this command:
xev | awk -F'[ )]+' '/^KeyPress/ { a[NR+2] } NR in a { printf "%-3s %s\n", $5, $8 }'
2. Press the key you want to remap to obtain the keycode:
135 Menu
In this example, the keycode is "135" and the keysym is "Menu"
3. In a text editor, enter this line:
keycode 135 = Super_R
4. Save the file in your home directory as:
.Xmodmap
(don't forget the dot "." at the beginning)
5. To apply changes, either reboot or run this command:
xmodmap .Xmodmap
Note that if you hotplug your keyboard by unplugging and plugging it back in, you will need to reapply the changes with the above command.
If you want to add comments to your .Xmodmap file, pre-append with "!" instead of "#".
Examples of other keysyms are shown here:
https://wiki.archlinux.org/index.php/Xmodmap#Modifier_keys
Other articles I referenced in the the video were:
https://wiki.archlinux.org/index.php/Xmodmaphttps://wiki.archlinux.org/index.php/Keyboard_input#Identifying_keycodes_in_Xorg
Attributions:
stainless-steel-keyboard-5-1550850 Photo by Andreas Just from FreeImages
Contact me:
Twitter: @sleepyeyesvince
MeWe: https://mewe.com/i/sleepyeyesvince
112 Comments