Insert symbols with the compose key

2020-07-21

Unicode is great. It contains all the imaginable symbols from all the worlds languages. Even mathematical operators and icons.

Your keyboard layout probably contains all the symbols you need to write in your language. If you need to write in two languages, switchind between their respective layouts is manageable. Provided they both use the same layout for basic letters just your numbers and symbols get mixed up. But what if they don’t?

Default for Czech is QWERTZ, for French AZERTY. This leads to a lot of pain.

Maybe you, like me, prefer to use the standard US layout and need to type some special or accented character only occasionaly. You can keep switching layouts if you have them set up. Or you can look up the symbol online and copy-paste it. You can insert the symbol using it’s Unicode code.

All of these ways have their problems.1 The layouts trouble I mentioned above. Looking up and copying the symbol is slow and cumbersome. Inserting by code means you need to memorize the codes otherwise you end up looking up the symbol anyway.

Truth be told, I really don’t see the point in memorizing unicode codes.2

Isn’t there was a better way?

A simpler, more memorizable way?

โ€ฆ

Turns out there is! And it has been here for a long time.

The Compose key, or โŽ„.

What the โŽ„ ๐Ÿ”—

The compose key was introduced in 1983 by DEC on the LK201 keyboard for the VT220 terminal.

LK201 Keyboard

On the Sun 5 keyboards the compose key was placed on the right end of the bottom row. Kind of in the area where the right Alt, Super and Ctrl are on modern keyboards.

Eventually, because of lack of support in Windows and Mac OS the compose key disappeared from modern keyboards.3

Setting up compose key in Gnome ๐Ÿ”—

Setting up compose key in Gnome is actually quite easy.

  1. Open GNOME Tweaks and navigate to the Keyboard & mouse section.
  2. Open Compose key settings (just under Emacs-input toggle).
  3. Bind the Compose key. The dialog offers multiple keys to map, right Super or Menu would be a good choice.

I set it up as right Alt as my laptop keyboard does not have right Super.

Using it! ๐Ÿ”—

So, how does it work? You press and release the compose key you bound earlier, then press and release two or more keys and it will input the corresponding symbol.

A few examples:

โŽ„ = E โ‡’ โ‚ฌ

โŽ„ c | โ‡’ ยข

โŽ„ S | โ‡’ โ€ฆ yeah no. turns out the $ is already present on a keyboard.

But you can do fractions โŽ„ 2 3 โ‡’ โ…”, greek letters โŽ„ / u โ‡’ ยต, accented letters โŽ„ c c โ‡’ ฤ, typographic symbols and much more. So, how do you learn the combinations?

Of course not by trying all the possible combinations. The relevant file is usually located at /usr/share/X11/locale/en_US.UTF-8/Compose.

wc -l /usr/share/X11/locale/en_US.UTF-8/Compose
6151 /usr/share/X11/locale/en_US.UTF-8/Compose

Whew, that’s a long file! Feel free to peek inside, but there are tables online listing the most common symbols.

Defining custom sequences ๐Ÿ”—

If you want, you can define your own sequences as well. First, copy the Compose file corresponding to your locale to your home directory as .XCompose:

cp /usr/share/X11/locale/en_US.UTF-8/Compose ~/.XCompose

Let’s add a line for the compose key symbol:

<Multi_key> <D> <O>			: "โŽ„" U2384

And now you can easily type โŽ„ as โŽ„ D O!

Wrap-up ๐Ÿ”—

Now you can insert special symbols in an easy mnemonic way without the need to switch layouts or look up their codes and it works everywhere on your system!

I myself only learned about compose key recently and could’t beleive I didn’t find out about it much earlier. Well, hopefully you learned something new as well!


  1. There are more ways of inserting symbols than I listed, but I never really used them. There is actually a third and fourth level on a keyboard accessed by AltGr and AltGr + Shift which give you some extra symbols and accents. ↩︎

  2. You might need to memorize codes that are not covered by the compose functionality. Or add them yourself. ↩︎

  3. There are now ways to achieve compose functionality on Windows and MacOS as well. Check wincompose or Karabiner-Elements. ↩︎