Monthly Archives February 2012

Re-mapping Keyboard Keys

Posted by admin on February 18, 2012  /   Posted in Linux

In Linux, it’s easy to remap one or more keys on the keyboard, in this article we’ll see how.

For remapping certain keys you need two tools: xev and xmodmap.

Start terminal window and run xev. Now it’s active and what’s for you pressing a key. Then press a key, it’s behavior you want to change. i.e. PgUp.

Notice the output of the terminal where you start xev from. You should see the following:

state 0x10, keycode 110 (keysym 0xff55, Prior), same_screen YES,

In this example Prior is the name of the action that the key is currently assigned to, remember the number after “keycode”, that’s the internal number for the key.

Now press another key i.e. PgDown, which should output:

state 0x10, keycode 115 (keysym 0xff56, Next), same_screen YES,

Remember the keycode number and the action name (Next in this case). Now let’s say you want to swap this both keys. Here we use the second program: xmodmap.

xmodmap -e "keycode 110 = Next"

This changes the action for the key with keycode 110 to “Next”. Do this for every keycode that you have remembered and apply any actions you wish.

NOTE: These change are for the current X session only and won’t survive a reboot. To do that, record all of the key mappings into a file called .Xmodmap using this command:

xmodmap -pke > .Xmodmap

Then enable this mapping from your .xinitrc (create one inside your home directory if you don’t have one already. Put this command in it:

xmodmap .Xmodmap

You’re done, now the new key mapping will be reactivated every time an X session is initialized for this user.


We serve businesses of any type and size
Contact Us Today