Home > Computer, System & Shell > Remap keys in Ubuntu

Remap keys in Ubuntu

A comfortable way to re-assign keyboard keys is by creating the file ~/.Xmodmap in the home directory, and putting line by line one re-assignment after the other. The typical format is ‘keycode <number> = <symbol>‘, but there are more possibilities (see ‘man xmodmap‘ or search for ‘Xmodmap’ for details). An example is:


keycode 112 = Home
keycode 110 = Prior
keycode 117 = End
keycode 115 = Next
keycode 134 = Delete

The number to the left identifies the pressed key itself. It can be determined by running ‘xev‘. The symbol to the right is the new action when the specified key is pressed without any modifier. You can define up to four space-separated symbols, where the second is applied if SHIFT is additionally pressed, the third if ALT, and the fourth if ALT+SHIFT. Use ‘NoSymbol’ if you do not want to let any action happen at all. For example:


keycode 16 = 7 slash NoSymbol backslash

This defines the mapping for key with keycode 16, which is usually the key labeled with ‘7’. The mapping defines to act like symbol ‘7’ when pressed without any modifier (note that the ‘7’ is the symbol for the number 7, but not a keycode as it would on the left). Further, SHIFT+7 gives slash, ALT+7 is ignored, and ALT+SHIFT+7 gives the backslash.

Changes are applied after logging out and in again.

Advertisements
Categories: Computer, System & Shell
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: