Although this document was originally written for the XFree-version of X, I have since changed to X.org, and I still use this setup. So although the document says XFree 4, it also works with X.org (version 6.8.2 as of this writing).
This document describes how to configure a compose-key (also known as multi-key) under XFree 4. A compose-key is a special key that allows you to type characters not found on your keyboard, by combining other characters. If you are using a language where special ligatures are needed from time to time (such as é), you will most likely be in a dilemma regarding either using dead-keys to be able to write these ligatures, or disabling dead-keys to allow faster typing of the characters that would otherwise be dead-keys, but are used as special characters. An example of such a character is ˜ (tilde), which can either be used as a ligature (as in ñ), or as a standalone character often representing the home directory of a user (˜user). Another example is the backtick character ( ` ).
If your setup uses dead-keys, you will need two keystrokes to type these characters. First you press the corresponding dead-key, which does not produce any output, then you hit the spacebar, which will produce the wanted character.
So what is this compose-key? It is a key used for telling your system that you want the next two keypresses to be combined to a single character, thus allowing you to type characters that are not found on your keyboard, but without having dead-keys enabled. A more correct term for the key is compose-character-key, but it is also known as a multi-key.
The main reason I found for using the compose-key instead of using dead-keys is that the two characters mentioned above (tilde and backtick) are commonly used in a Linux environment, and it would therefore be desirable to be able to type these characters with less keystrokes. The ligatures are not often used, and can be typed using the compose-key.
Configuring a compose-key under X is not difficult. First we will need to determine the keycode of the key we want to use. To do this, use xev. Open a console, start xev and press the desired key. I use scroll-lock, which has keycode 78:
KeyPress event, serial 26, synthetic NO, window 0x1c00001,
root 0xae, subw 0x0, time 2133201, (167,-11), root:(175,55),
state 0x0, keycode 78 (keysym 0xff20, Multi_key), same_screen YES,
XLookupString gives 0 bytes: ""
KeyRelease event, serial 26, synthetic NO, window 0x1c00001,
root 0xae, subw 0x0, time 2133365, (167,-11), root:(175,55),
state 0x80, keycode 78 (keysym 0xff20, Multi_key), same_screen YES,
XLookupString gives 0 bytes: ""
Now that we know the keycode, we are ready to configure this key as the compose-key. This is done using the Xmodmap. You can either configure it globally by editing /etc/X11/Xmodmap or for a single user by editing ˜/.xmodmap. In both cases you should insert the following line:
If you want to test the configuration before putting it in the file, you can invoke xmodmap from a shell with the -e-option:
[spiff@spiffship spiff]$ xmodmap -e "keycode 78 = Multi_key"
After making sure the compose-key works as expected, you might want to disable dead-keys in X. This is done by adding the following line to your /etc/X11/XF86Config in the InputDevice-section defining your keyboard:
You should now be able to use your compose-key to type the combined characters, for example:
| key sequence | character |
| compose a a | å |
| compose A A | Å |
| compose o / | ø |
| compose a e | æ |
| compose o e | œ |
| compose ' e | é |
| compose c o | © |
| compose s s | ß |
You can find some of the combinations by running this command in a console:
[spiff@spiffship spiff]$ dumpkeys | grep compose