You may want to remap your keyboard for various reasons including comfort and convenience. Invariably, you will want to move a key that you use regularly and is in an irritating position (eg CTRL, ALT or Page Up/Down) to a key in a better position. The keys that you want to move, of course, will be entirely dependent on the keyboard that you use.

In Windows, remapping a keyboard is relatively straightforward - you can install a program called Sharp Keys and follow the necessary steps.

In Linux (I'm using Ubuntu 15.10), remapping your keyboard is slightly more complicated, but nothing that you should shy away from.

Open your terminal and run the command xev. This will open an 'event tester' window. Whenever an event occurs (eg you move or click the mouse, or you press a key on the keyboard), an event notification will be output to your terminal.

For example, if I press the letter h the following is output to the terminal:

KeyPress event, serial 37, synthetic NO, window 0x4e00001,
    root 0xd4, subw 0x0, time 23532892, (-1414,522), root:(9,705),
    state 0x0, keycode 43 (keysym 0x68, h), same_screen YES,
    XLookupString gives 1 bytes: (68) "h"
    XmbLookupString gives 1 bytes: (68) "h"
    XFilterEvent returns: False

KeyRelease event, serial 37, synthetic NO, window 0x4e00001,
    root 0xd4, subw 0x0, time 23532972, (-1414,522), root:(9,705),
    state 0x0, keycode 43 (keysym 0x68, h), same_screen YES,
    XLookupString gives 1 bytes: (68) "h"
    XFilterEvent returns: False

If I press Page Down the following is output to the terminal:

KeyPress event, serial 37, synthetic NO, window 0x3c00001,
    root 0xd4, subw 0x0, time 24228461, (-476,433), root:(947,616),
    state 0x0, keycode 117 (keysym 0xff56, Next), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 37, synthetic NO, window 0x3c00001,
    root 0xd4, subw 0x0, time 24228533, (-476,433), root:(947,616),
    state 0x0, keycode 117 (keysym 0xff56, Next), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

To stop xev running at any time, ensure that the focus is on the terminal and press CTRL + Z.

The pieces of information that you want to pull out of this output are the keycode and the keyname. For the key 'h', this is keycode 43 and keyname h. For the key Page Down the information is keycode 117 and keyname Next.

Other keycode/keyname mappings on my keyboard include:

Backspace: 22, BackSpace
Left Arrow: 113, Left
Right Arrow: 114, Right
Right Control: 105, Control-R
Menu: 135, Menu
Scroll Lock: 78, Scroll_lock
Page Down: 112, Prior
Pause: 127, Pause

I like to remap my Menu key to perform the same function as Page Down. To do this, I use xmodmap in the terminal:

xmodmap -e "keycode 135 = Next"

Hey presto, your keyboard has been remapped. I also like to remap my keyboard so that Pause performs the same function as BackSpace and Scroll Lock performs the same function as Page Up. To do this I use:

xmodmap -e "keycode 78 = Prior"
xmodmap -e "keycode 127 = BackSpace" 

Now, I have two separate keys which I can use for page up, page down and backspace. These mappings don't last forever - your keyboard configuration will be reset each time you restart your computer. You can work around this issue in two separate ways: