§Two kinds of console

Linux console is the terminal you see after hitting ctrl+alt+F[1…6]. Terminal emulators are GUI apps under X, such as xterm, guake, etc. One needs to be clear which one they want to perform the remapping, because they have different configuration for keyboard mapping.

Keycodes is the identifier we will be using to distinguish each key. (How to obtain keycodes is covered in [ArchWiki].) Reprint from the same [ArchWiki]:

Note that the keycodes are different for Linux console and Xorg. Use the appropriate tool to determine the desired value.

§Linux console:

§Debian family

dpkg-reconfiguration keyboard-configuration

It brings out one text menu to set the main keyboard layout. (Fine tunning comes after.) This command basically write your preference to /etc/default/keyboard. I use Colemak layout, but I still want Capslock to function like Control, so I have to do this kind of mapping manually (tunning). /etc/kbd/remap is made obsolete by console-setup, so head to /etc/console-setup/remap.inc to do your remapping. . The following is basically my /etc/console-setup/remap.inc:

keycode 58 = Control   # capslock
keycode 100 = Return   # right alt
keycode 97 = Caps_Lock # right ctrl

§Bare Linux

Debian really tries hard to make everyone’s life easier. In this case, it’s the /etc/default/keyboard, that provides one interface to change the keyboard in both Linux console and terminal emulators. Just use Debian, if you don’t want to spend too much time on configuring your box. The following is for people who have more spare time and curious about what’s happening behind the scene.

this briefs on how to use loadkeys and other related stuff.

§Terminal emulator

xmodmap is responsible for keycodes translation. Similar to previous case, we have one tool, xev, to identify keycodes.

§Reference

http://superuser.com/questions/290115/how-to-change-console-keymap-in-linux

http://askubuntu.com/questions/24916/how-do-i-remap-certain-keys

  • Nocap This guy finds capslock repellent, but I do use it sometimes.