Today I started hacking the us keymap of xorg to define my own custom keys. That's so funny.

For people interested, here is how to do it:

% cd /usr/share/X11/xkb/symbols
% cp us mykeymap
% vi mykeymap

So far it's simple.

Delete everything but keep the xkb_symbols "basic" { } part. The format is quite simple, so I won't explain it. I decided to use the right alt key to map several characters I want to use. For this, you have to add include "level3(ralt_switch)" after just before the last bracket.

You can now add other characteres, for example I changed:

key <AB03> {        [         c,    C         ]       };

to

key <AB03> {        [         c,    C,    copyright,   registered      ]       };

So I can type the copyright symbole (©) by pressing Alt right and c, and the registered symbol (®) by pressing Alt right, shift and c.

The characters name are located in the /usr/include/X11/keysymdef.h file.

You can change your keymap with setxkbmap mykeymap and to change it definitely, just edit your /etc/X11/xorg.conf.