The Compose Key
Last Updated: 2025-10-09
The minor fall, the major lift
The baffled king composing "Hallelujah"
Overview
The Compose key is extremely useful and configurable, but often disabled by default, and something lots of people are unaware of. Here, I'll explain it, and help you to start using it, if you like.
First, the bad news: the Compose key I'll discuss here is an X11 feature [note 1] — not available on Windows [note 2] or Mac. I will mention some Windows/Mac semi-equivalent features, but mostly to demonstrate why the Compose key is better (:
The concept of a Compose key has a long history, not specific to UNIX or X11, but I'll leave that aside. Feel free to go down that rabbit hole if you want.
The Problem
There are limited keys on a keyboard, and we often want to enter other characters, such as accents (é) umlauts (ü), mathematical symbols (∃), special punctuation (¿) and the like. The Compose key solves this problem neatly. You press the Compose key (optionally release it), then another key, or sequence of them, and the appropriate special character is produced. This works system-wide, not just in certain programs.
I'll go into more details in a moment, but first: here are some other ways of typing special characters, so we can compare and contrast them with the Compose key:
Other Solutions
We can, of course, press Shift to access a second set of characters on the keyboard (eg: the 1 key becomes !, the / key becomes ?), but there is only one Shift key, so the assortment is still quite limited.
On Windows, you are perhaps familiar with "Alt codes."
Basically, you press the Alt key, and then a sequence of numbers on the keypad.
For instance, Alt+0151 will produce an em-dash (—).
This works, but it is rather limited in practice, since you have to remember arbitrary numbers, which are not particularly related to the thing you want to type. Here's a useful reference sheet I found while researching.
Another option on Windows is the "Character Map" program, where you can select special characters from a grid.
This can be frustrating, since you have to visually scan a large field of characters to find the one you want.
Yet another option is the "emoji picker" accessible via Windows 10's [win]+. shortcut, though its choices are limited.
None of these options is configurable or extendable.
On Mac computers, one can press Alt and Alt+Shift to access more alternate characters, akin to how the Shift key behaves. For instance, Alt+Shift+2 on a US keyboard gives "€". A decent reference is here. [note 3]
This is okay for common cases, but we have limited modifier keys, and there are a *lot* of interesting symbols we want to write.
Macs also have a Character Viewer tool, similar to Windows, with similar downsides.
The "Alt+Shift" method can also be used to activate so-called "dead keys" (Mac docs). The dead key approach is almost as good as a Compose key, but only supports a few common cases (such as adding accents), so lacks generality. It is also not configurable. Once a given dead key is activated, such as the "add an acute accent" one, then the next normal letter you type will have that accent applied.
Some keyboards, especially outside the US, have an "AltGr" key, which has a similar purpose to "Alt+Shift" on a Mac — in truth, the AltGr key came first. This is used both for inputting alternate characters and for activating dead keys. Also, some specific applications (such as word processors) have their own particular ways of inputting special characters — such as "(c)" becoming "©" — but we'd like an approach that works the same way everywhere.
Note: one case where the compose key can be slightly inferior is when typing in languages that make heavy use of a small number of accents (eg: French). In these cases, an AltGr/dead-key approach can be better, since it involves fewer key presses.
The Compose Key
With that background, we finally arrive at the true subject of this article — the Compose key! The big advantages of the Compose key are that its sequences are (1) easier to remember, (2) easier to guess, compared to the other approaches discussed above, and (3) customizable.
For instance, to add an acute accent to "a", we type [compose] a ', producing "á."
Once you know that, you can probably guess how to type í and é as well — it's very similar.
To do a grave accent instead, you just use ` instead of ' in the sequence.
You can also probably figure out how to type "ñ" pretty quickly.
It is [compose] n ~ You can have some fun guessing other ones, too — "??" produces "¿". And now you probably know how to type "¡", as well (:
Accents are easy though, and dead keys handle them pretty well, too. But the Compose key can do more. Here are some simple examples, just to give you an idea (I omitted the "Compose" prefix, for clarity).
=> → ⇒
c/ → ¢
tm → ™
CO → ©
v/ → √
=/ → ≠
I didn't need to look those up, and I don't have them all memorized; but I figured them out quickly just now while typing.
But there's more!
These mappings are fully configurable. For instance, I mapped "pho" to phở on my system, and "eh" becomes ¯\_(ツ)_/¯.
Enough talk — turn it on!
Sadly, the Compose key is probably not enabled by default on your system. Assuming you are in an X11 session, we'll first turn it on for just that session. Then I'll show you how to turn it on in a more permanent way.
The first thing you need to do is pick a key on your keyboard which will act as the Compose key. It should be a key that you don't use much for other things. One good choice is the "windows key" if your keyboard has it — maybe just the left or right one, if there are two (see below). Personally, I use those for other things on my system, so I use the Pause/Break key as my Compose key.
The command to enable it in your current session is:
setxkbmap -option compose:paus
Note: if you wanted to use the windows key instead, you'd use:
setxkbmap -option compose:lwin -option compose:rwin
As you can see, you could also just use *one* of the windows keys for it, since there typically are two on a keyboard.
After running that command, you should be able to open a new terminal, and start using it!
A favorite of mine is the CCCP sequence (:
If you want to turn it on more permanently, there are two (or three) ways:
Option 1: You can add the above setxkbmap command to your .xinitrc file, or some other early startup script for your system.
The problem here is that if you disconnect/reconnect your keyboard, the association will be lost, and you'll need to manually run the command again.
I do that frequently (ask me about my VM setup), so I found another way:
Option 2: You can also add a bit of X11 configuration.
The location of files can vary slightly by system, but on mine (Debian), I added a file at /etc/X11/xorg.conf.d/10-kbconfig.conf, with the contents:
# This matches all keyboards, and applies my options.
Section "InputClass"
Identifier "My Keyboard Settings"
MatchIsKeyboard "on"
Option "XKbOptions" "compose:paus"
EndSection
This will be freshly applied each time a keyboard is attached.
Option 3: Depending on your desktop environment, there might be a GUI configuration option available to you. For instance, I have read one report that Ubuntu has a setting in "System → Preferences → Keyboard → Layouts → Options" to specify it. In KDE, it is "Settings → Input Devices → Keyboard → Advanced → Position of Compose key." I don't have personal experience with those, though. This applies to systems running Wayland, too; the /r/linux discussion for this article has some good info.
Customize It
Now that it is activated, let's cover customization:
Create a file called ~/.XCompose (case sensitive, of course — this is UNIX after all).
For full details, read the manpage for it: xcompose(5), but I'll cover some basics here.
Importantly, this file will *replace* the default Compose key configuration, not add to it. You probably want to keep that stuff though, so I recommend the first line of your file to be:
include "%L"
This just tells it to include the system-wide default file first, before your modifications. Then, you add your own sequences below, one-per-line.
For the format, I'd recommend just reading the system-wide one to understand it.
On my system, that file is located at /usr/share/X11/locale/en_US.UTF-8/Compose; your manpage should tell you what's right for your system.
Alternatively, you can read an online version here (for the en_US.UTF-8 locale): https://www.x.org/releases/current/doc/libX11/i18n/compose/en_US.UTF-8.html I often just copy a line from the existing config, then modify it to suit my needs. It is a simple format.
Gotchas
For some reason, on my system, the default file has a bunch of blank space at the top. This initially confused me because it looked like an empty file when I first opened it. You might have to scroll down a bit (:
Beware: for a backslash in the quoted output string, you need to escape it, like so: \\.
You can search in the default config files for examples of that.
Also, the naming of input characters can be a little odd in some cases. For instance, the ^ character is called "asciicircum."
The Compose key itself is called "Multi_key."
You can use the xev program to discover these names, if you can't find an example to copy.
Also of note, you must be careful to avoid specifying a sequence that is a prefix of another one.
You won't be able to enter the shorter one, since the Compose framework will keep waiting for you to enter subsequent key(s) for the longer sequence(s), with no way to cut it short.
One workaround: specify some unused key, such as Escape as a "sequence terminator" for the shorter one.
There are a lot of good sequences in the default file which you might not be able to actually type.
For instance, Greek letters are prefixed with the dead_greek key — but I don't have that key on my keyboard, so I can't produce that sequence.
I duplicated those lines in my config and changed dead_greek to g, to make them typeable for me, θυσλψ. [note 4]
Furthermore, beware: when you make changes to your .XCompose file, they will not become immediately active.
The file is generally read once during each program's startup.
So, you typically need to re-start a terminal or other program in order to start using your changes.
And that's it — happy composing!
Soon, you too will be annoyed at not having it available in other systems (:
– John
Discussion:
Footnotes:
- It also works in Wayland, which uses XKB.
- But see the WinCompose project.
- Of course, keyboards and OSes in other countries behave subtly differently.
- That was my attempt at "thusly" :-þ
If you like these articles, feel free to sign up for the mailing list:
We also have some social media links, if you want to follow or contact us.