
Suppose, for example, that you want to get a period instead of a comma on the numeric keyboard (useful for most programmers), but you want to keep the "delete" behavior when NumLock is off.

Xmodmap -e "KEYCODE MODIFIER = behaviour behaviour_with_modifier" Like how the keys in the numeric keyboard depend on NumLock) you simply have to do xmodmap -pm to get a list of modifiers and then do:

If the key you are remapping has different behavior depending on a state ( Xmodmap from console to see the changes immediately. xinitrc in your home directory where you put command xmodmap. When you want to save the changes permanently you have to run the following commands after the ones above: xmodmap -pke >~/.Xmodmap Note: These change are for the active X session only and will be lost after reboot. You can see the concrete sequence for your layout by finding it in one of the files in /usr/share/X11/xkb/symbols/. Here is a comprehensive list of all keysyms. It usually is Key, Shift+Key, mode_switch+Key, mode_switch+Shift+Key, AltGr+Key, AltGr+Shift+Key, but can be very different for more special layouts, like in case of the German Neo 2 one.
#Remap keyboard keys windows code
For example if you want the key with code 53 to map to backslash normally, but to the bar symbol when used with shift, you might do: xmodmap -e "keycode 53 = backslash bar"Īdditional information: The sequence of these mappings depends on the keyboard layout. Note that if the key you are mapping should have a different meaning when used with the Shift key (for example for British keyboard layouts, Shift+ 2 gives quotation marks) then you can simply list the secondary command after the first. This changes the key with keycode 110 on your keyboard to the action Next. Now when you want to swap the two keys use xmodmap. Here again the interesting part for us is keycode 115 and Next - the name of the behaviour. PgDown give this output state 0x10, keycode 115 (keysym 0xff56, Next), same_screen YES, In this example Prior is the name of the behaviour the key is assigned to at the moment, the number keycode is the internal id to recognize the key. It should look similar to: state 0x10, keycode 110 (keysym 0xff55, Prior), same_screen YES,

Xev will output some information about the pressed key. Then press the key whose behaviour you want to change. Now it's active and waits for you to press a key. Both should be available in Ubuntu without extra installing them. First xev (command-line tool) and second xmodmap (also command-line tool). The answer below is no longer relevant for current releases.įor remapping certain keys you need two tools. Notice: As of 2013, Ubuntu and derivatives no longer use xmodmap, but instead use xkb.
