Adjusting your key mapping

Changing your keymapping in debian is slightly complicated by the number of different applications and layers. For example to change the keymapping in the console is easy just copy the default keymap file from the drivers section of your linux source directory and adjust it to suit you setting.



   $ cp /usr/src/src-linux-2.4-benh/drivers/char/defkeymap.map ~/Keymaps/



I then opened the file in vim and changed:

   "keycode 1 = Escape Escape"

to

   "keycode 100 = Escape Escape"

I then loaded this file using the command:



   $ sudo loadkeys ~/Keymaps/defkeymap.map



This mapped my right Alt key to ESC which makes it much easy to use. The Esc key is used a lot in Vi switching from command to insert mode.



Before I go any further I will just mention the programs that you can use to see what your current keymappings are. The tool that is quite useful to see what your current keymapping is in the console is dumpkeys. For the X windows environment the most useful tool I found is the xev tool which in debian is part of the xbase-clients package. This tool lets you press on the key and see what the keycode is.



To change the keymapping in the X environment is complicated by the fact that some applications let you set the key bindings, gnome-terminal version 2 for example. To set the key mapping for the X environment I simply added the following lines to my .xsession script

xmodmap -e "keycode 115 = Escape"

xmodmap -e "keycode 113 = Escape"

xmodmap -e "keycode 117 = Control_L"

I added 2 mappings for the Escape key because I use 2 different keyboards, the keyboard on my Ibook and a usb keyboard that I plug into it when I am working at my desk.