Linux Compose Key
2009-11-26
I often need to type characters that aren’t on the keyboard, like ½ ÷ © ¥ or ¢.
On Mac, they’re done with the [option] key, but not always intuitive. For example: © is [option]-G and £ is [option]-3. I never did memorize all of these combinations, but there’s a nice cheat sheet of Mac accent codes, here.
On Windows, it’s horrible. You need a separate numeric keypad on your keyboard, then you use the [Alt] key plus a 4-digit unicode number to create the character. For example: © is [Alt]-0169 and £ is [Alt]-0163. See Windows alt codes, here.
On Linux, though, they have the most brilliant intuitive way of doing this:
You pick a key on your keyboard you don’t use much, like [Insert], [CapsLock], or [menu], and make it the “compose key”.
Then to make any character, you just hit the compose key, then type the two obvious keys that, when combined, make up the character.
For example:
- To get ©, just type c then o (Get it? It’s like drawing. The letter c, then a circle.)
- To get £, just type L then - (like L with a line through it.)
- To get ¥, just type Y then =
- ¢ is c then |
- ÷ is - then :
- ½ is 1 then 2
- ñ is n then ~
It’s like drawing with your keyboard!
Best of all: I never need to read a manual. Drawing characters like this is so intuitive that my first guess is always correct. That’s the core of usability, right?
See the Wikipedia page for more info.
(Windows people, don’t despair. There’s a free tool called AllChars that will let your Windows PC have this cool compose key function. Try it! It’s fun!)


The problem with my keyboard isn't that (or the missing key top), but that I tend to wear the printed characters off the keys themselves. So when that finally happens, I have to remember the feeling of the location of keys in the QWERTY layout.
The Unix/Linux systems have always been *so* far in advance of others, especially in terms of common sense.
Nice!

And we can define our own compositions too. Love the freedom
https://help.ubuntu.com/community/ComposeKey
Thanks, Derek.
You are so helpful. I've downloaded the Mac chart and will use it regularly.
I love using special characters just for that, "Wow, how'd you do that?!" factor… >;-D I'll enjoy that Mac chart, although for the most part I find the Mac combos pretty intuitive.
Any idea if there is a Mac equivalent?
No, but Mac option-keys aren't bad. -- Derek
Set your compose key from a shell or a script with
'setxkbmap -option "compose:ralt"'
(if you want your right alt key to become the compose key).
To get ¥, just type Y then =
Not correct. Should be: To get ¥, just type Y then - ...
Pedro: you can do quite a bit with the OS X text system: http://hcs.harvard.edu/~jrus/site/cocoa-text.html
I have all kinds of shortcuts for special characters of various sorts.
While I agree that the "composable" nature of the L + - makes more sense when wanting £, at least visually, having £ be on option-3 key makes some sense because shift-3 is #, which is called "pound" in some areas.
I think the problem is that the non-visual nature of non-Linux methods of doing it breaks down because it isn't consistent. While option-3 has potential to make sense semantically, option-G for copyright seems to be a more "visual" mapping (a circle with something in the middle -- in which case option-2 might make _more_ sense). The "compose _everything_ visually" is definitely much more powerful because you know how the thing you want looks, but may not be familiar with how someone thought about how the meaning behind the character maps to already established conventions.
Now if only I could run Cubase, Protools, and Photoshop on Linux!
Here's what I do On Mac to stay on top of accents. IMHO, accents on names are very important not to gloss over.
System Pref > International, tick the box next to "Keyboard Viewer"
This adds the Keyboard Viewer to your languages, up in the top right. (Probably hidden under your flag.)
With the Keyboard Viewer window open, you can see what keys are transformed when you hold down option.
The orange keys are modifiers. Hold opt, hit an orange modifier, and then the letter you want to put that accent over. And they're fairly intuitive if you speak french, think of the letter that most commonly uses that accent.
Opt n, n makes ñ
Opt e, e makes é
Thank you for the alt codes for windows!
For the last decade and a half I've used copy and paste from the character map.... useful for a quick fix, highly irritating for a long document!
Love this! Thanks!
This is by far your best post ever!
Long live the penguin.
@Joel Laviolette II
Yeah, if only you could write to the companies that make this software and ask them if they could maybe make a Linux version.
You can do this on Windows too, no problem.
' + e = é
" + e = ë
^ + e = ê
...but of course you don't get the configurability of Linux. So things like '- + L = £' are not supported.
HOWEVER, this has been a standard feature in Windows for quite some time. At least since the mid-nineties. I do think that it depends on which keyboard layout you're using.
So the ALT+xxx stuff you're talking about is WAY outdated, except for the very uncommon characters. You just look these up in the character map (point + click).
To be fair, it's not a Linux thing. It's an X thing.
Fun post. Thanks~~
Thanks Derek,
Having been a Mac guy for decades now, I appreciate the more complete list of option keys (proud to say I already knew many of them).
Linux always is a step ahead..
I'm using Ubuntu 9.10.. Its cool...
How about a cyrillic alphabet, or Mandarin? All computers should have the major symbol sets of the world on them. Puzhalsta!
that's very cool thanks derek, i've often threatened to change my os to linux is so totally over windows one of these days by gum by golly i'm gonna do it. ;)
That's great!
I don't knew about it.
Congratulations by the post!
Another way of doing this same thing is to change your keyboard to US-International (with dead keys). In that mode, you can press two keys in order to get special characters. For example é is ' then e, and ç is ' then c. Other keys are also available: ñ = ~ n.
Some of the combinations are slightly more difficult (but they make sense to me). For example, © is [right-alt] + [c], and £ is [right-alt] + [shift] + [4] (the $ key). × is [right-alt] + [=], ÷ is [right-alt] + [shift] + [=].
I use this keyboard setting in all my OS's, so the "composing" is consistent throughout.
As a forewarning, there are some odd keys, like 's in some programs. (not this one, apparently). How you get around that problem, is simple type space in between those letters. It always works, and can become your finger's standard.
I wrote a bit about setting up my keyboard (including turning on a Compose key) at http://canonical.org/~kragen/setting-up-keyboard.html and there's an extended "compose" file at http://github.com/kragen/xcompose — it includes a bunch of things like ♯ and ☞ and → and ∃ and ☺ and ∎, plus the whole Greek alphabet. (When would I use these? Well, I use → quite a bit, ☺ and ☎ are mostly for use in IRC, ∃ and ∀ and ≠ are handy when talking about math, etc.)
I don't know that I agree that the standard compose sequences (in e.g. /usr/share/X11/locale/en_US.UTF-8/Compose) are entirely intuitive. Frankly I think Ą (;A — not ,A like ç and ȩ), š (cs), and ṃ (!m) are just weird, but at least they're consistent; there are weirder things like "oc" for "©", but "(3)" for "③". But they're a heck of a lot more memorable than numerical Unicode code points like Microsoft's solution.
"¢ is c then | " – just curious, why not "c then /" ?
Joel Corriveau – thanks so much for posting that for Mac users, I'd never explored this before!
In case others aren't finding "International" in System Preferences, on some Macs it's "Languages & Text" then go to "Input Sources" ...
In addition to the keyboard viewer, you can also turn on the character viewer and just insert all the crrrrazzzy characters you like into whatever you're typing right from there!
The ever-useful for music folks © and elusive ℗ (sound recording copyright - shows who owns the "master" recording) can be found in the character viewer under "Miscellaneous" (along with a ton of other international, math, currency, and decorative goodies).
Character party!
♥☺☆€≈∪⇔∝∞②¾ĦĐÞțźįħåöøæïŏă☀☁☂☃
Oh, short vowels, how I have missed you so.
Ooh, and also under system preferences, go to the "Text" feature – you can compose! And with more than 2 keys if you like (useful for things like (p) = ℗
FWIW: Sun workstations/keyboards have shipped with a Compose key already there with this same functionality (in their OSs) going back to the 80s..
MS Word has actually had a very similar system for years. It doesn't do all the symbols (like division), but, for example:
ctrl-` shift-a gives À
ctrl-, c gives ç
ctrl-' i gives í
ctrl-~ (ctrl-shift-`) n gives ñ
ctrl-^ (ctrl-shift-6) o gives ô
ctrl-: (ctrl-shift-;) e gives ë
not quite as complete as unix, but it gives you what you need most of the time.
Thanks man ! Stumbled.
In case you're still wondering, £ is accessed on US keyboards by option-3 because it is shift-3 (in place of the $) on British keyboards.
The customizability of linux is awesome. I have currently use both the compose key and 3rd level modifier, with an alternate greek layout.
«€®©£ź×ĥ„“čǎ λμπαςσδχζψωφρδεωβ»
"Matt J (2009-12-21) #
In case you're still wondering, £ is accessed on US keyboards by option-3 because it is shift-3 (in place of the $) on British keyboards."
Not so. The dollar is also on UK keyboards and in the same place as on US keyboards - on the (shift) 4 key. The differences are on the 2 key (@ instead of ") and the 3 key (# instead of £)
No interrobang‽ Denied!