You can type characters beyond those on your keyboard in most X programs that use keyboard input (terminal emulators, web browsers inside text areas, etc.). This is done with libX11's Compose(5) feature. A multi-key input sequence is mapped to a character; for example, <Compose> <e> <'> generates the character é.

Once you have set this up, you can type accented letters (é å ù), other European characters (ç ñ), Greek letters (α β), or whatever else you choose to configure.

Compose key configuration

The first step is to define a Compose key, also known as a Multi_key key. Many people choose to use one of the "Windows" keys, or the "Menu" key, or one of the "Alt" keys. For available variants see Position of Compose key and Key to choose the 3rd level in xkeyboard-config(7).

System-wide

Keyboard configuration dialog includes a step to select Compose key. To start it, run as root

# dpkg-reconfigure keyboard-configuration

Settings are saved to file:/etc/default/keyboard. The XKBOPTIONS variable there should contain something like compose:ralt. For more details see Keyboard. Desktop environments may ignore changes of system-wide configuration and use settings saved during earlier sessions.

Xmodmap

Whichever key you choose, run an xmodmap command to assign it a new meaning. For example, to use the Left Windows key:

xmodmap -e "keysym Super_L = Multi_key"

Make sure this command is executed whenever you login to X, for example by placing it in your ~/.xsessionrc file. Other files may be used, depending on how you start X, which Desktop Environment you use, and so on.

Compose sequences

Once you have defined a Compose key, you should immediately be able to type the basic accented letters in a terminal emulator. The full list of default compose sequences may be found in /usr/share/X11/locale/en_US.UTF-8/Compose for reference. If you're happy with these, you may stop here.

The second step is to configure your own custom compose sequences. To do this, create a file named ~/.XCompose and make sure it has include "%L" at the top of it, to bring in the default sequences. After that, you may put whatever you like. For example,

include "%L"

<Multi_key> <g> <a> : "α"
<Multi_key> <g> <b> : "β"
<Multi_key> <g> <g> : "γ"

This file is read by libX11 whenever a new X program is started. So, your existing terminals won't be able to type these new characters, but any new terminals you launch will.

There is a bit of a chicken-and-egg issue with getting the desired characters into the .XCompose file in the first place. The easiest way is to find a web page that has the character(s) you want, and copy and paste them into your .XCompose definitions.

If you are unlucky with Web search you can try to install applications like gucharmap or kcharselect that they allow to search the character by name or Unicode number, i.e. for searching the alpha character then you type "Greek" for the Greek alphabet. If you have trouble with characters visualization, it could depend on installed fonts, try to install fonts-recommended package before asking to the community.

KDE Way

There is a simple GUI config to set a Compose key in KDE.

systemsettings/hardware/keyboard/advanced
Enable config keyboard options
Disable annoying caps-lock
Set position of Compose key to caps-lock

The list of all the codes is in /usr/share/X11/locale/en_US.UTF-8/Compose - more bits under other specific locale.alias..

Also see


CategoryDesktop