
Creating and Compiling Custom Keymaps for Linux
Introduction ......................................................................................................................................... 2
Step 1: Retrieve keymap sources ........................................................................................................... 2
Step 2: Modify keymap and symbols ..................................................................................................... 2
Step 3: Compile keymap ...................................................................................................................... 3
Step 4: Install the new keymap .............................................................................................................. 4
More knowledge ................................................................................................................................. 4
Declare symbol using unicode ........................................................................................................ 4
Get key name by keycode ............................................................................................................. 5
Combining keymaps ..................................................................................................................... 5
Extra keys using Alt+Gr ................................................................................................................. 6
Old and new code ....................................................................................................................... 6
For more information ............................................................................................................................ 7

Introduction
HP thin clients running the ThinConnect operating system use compiled keymaps to reduce the amount
of flash disk space required to support a large set of international keyboards. This white paper
describes the basic steps involved in creating custom keymaps for keyboards that are not supported
by default under ThinConnect.
The examples in this white paper are based on Debian Etch and Xorg 7.1. All work should be
completed from a system based on Debian Etch, such as the HP t5735. The resultant keymaps from
the examples have been validated on the HP t5735 and HP t5135 running ThinConnect (S2ST0070).
Step 1: Retrieve keymap sources
1. From the command prompt, execute the following command:
wget http://ftp.de.debian.org/debian/pool/main/x/xkb-data-legacy/xkbdata-legacy_1.0.1.orig.tar.gz
If that URL no longer exists, search http://packages.debian.org for the package xkbdata-legacy and download the .orig.tar.gz file.
2. Go to the directory /home/user and extract the .orig.tar.gz file using tar –xzf <file>.
Step 2: Modify keymap and symbols
In this simple example, you will replace the $ in a US keymap with the sign for yen, ¥.
1. First go to the directory /home/user/xkb-data-legacy-1.0.1. This is the base directory
(<base>) for the remainder of the example.
2. Open the file <base>/keymap/xfree86 for editing.
This file provides declarations for most types of keymaps. In this example, the “us” keymap is
used as a base.
3. Copy the xkb_keymap “us” section and paste it directly below the ‘};’ line that closes out the
“us” keymap. Since there cannot be two default keymaps, remove the “default” header from
the new keymap, and rename it “my_map” as shown below:
xkb_keymap “my_map” {
xkb_keycodes { include “xfree86” };
xkb_types { include “default” };
xkb_compatibility { include “default” };
xkb_symbols { include “us(pc105)” };
xkb_geometry { include “pc” };
};
At this point you have a keymap identical to the us keymap.
4. Now change the xkb_symbols line to match the following:
xkb_symbols { include “us(my_keys)” };
This will change the keymap so that it uses the symbols declaration “my_keys” in the symbols file
“us”. However, this symbols declaration does not exist yet; the next step is to create it.
2

5. Save and exit the xfree86 file and open <base>/symbols/us.
This file contains declarations to map all the keyboard keys to symbols for the us keyboard. Other
files in the <base>/symbols directory will map symbols for other keyboards. For example,
<base>/symbols/de contains declarations for all the German symbols, and
<base>/symbols/jp contains symbol declarations for 106 key Japanese keyboard.
For a simple modification such as this one, you can add a new keyboard declaration to the us symbol
file instead of creating a new symbol file. Go to the end of the us file and add the following lines
directly below the ‘};’ line that closes out the previous symbol declaration:
xkb_symbols “my_keys” {
include “us(pc105)”
key <AE04> { [ 4, yen ] };
};
The include line declares that this symbol definition will inherit all the keys declared by the symbol
definition pc105 in the symbol file us.
If you trace the include lines from the declarations you will see that it inherits most of its keys from
us(basic) which contains all the letters and number keys and us(generic101), which contains
most of the control and auxiliary keys. It can be very helpful when creating a new keymap to look at
existing symbol declarations, such as these, to see what the symbol declarations should look like.
The key line below the include line declares a new key name to symbol mapping. It will take the
key <AE04> and map it to the symbol 4 normally, or yen when the Shift key is pressed.
The alphanumeric section of the keyboard is referred to as <Ax##>, where x is a row letter starting
with the row (A) where the space bar is located, and ## is a number starting from the left side of the
keyboard (ignoring the special keys like the left single-quotation mark/tilde key [` or ~]), Tab, Shift,
etc. Using this convention, the E key is <AD03>, the forward slash (/) key is <AB10> and the numeral
5 key is <AE05>. The special keys all have their own names such as <SPCE> for the spacebar,
<TLDE> for the left single-quotation mark/tilde key key (` or ~) and <L_ALT> for the left alt key.
These keys are all defined in <base>/keycode/xfree86. When a keyboard key is pressed it
generates a integer called a keycode; keycodes are mapped to key names by the keycode file
declared on the line:
xkb_keycodes { include “xfree86” };
in the keymap declaration.
If you are unsure as to what the name for a key is, the best way to find out is to look at a symbol
declaration for a keyboard you know and find where the key is declared. For example, if you did not
know what the key for the backslash was called (usually right above the Enter key on a standard us
keyboard), you could look for ‘backslash’ in the us(basic) symbol declaration, and on line 258 find
that it’s called <BKSL>.
You could also do this in reverse to find what the symbol is called. For example, if you knew that on a
French keyboard the 12
pressed with the Shift key, but didn’t know what to call that symbol, you could look for <AD12> in
<base>/symbols/fr and find that it is called sterling.
th
key on the 4th row from the bottom <AD12> created a £ symbol when
Step 3: Compile keymap
Now that you have created a new keymap and symbol declaration you are ready to compile the
keymap. This is done via this command:
3