A compose key for macOS on a QWERTY layout: tap the right alt (Option) key,
then type a short sequence to insert an accented letter or symbol. For example,
alt + ' + e types é.
Unlike a dead key, the keys of a sequence can be typed in any order
(alt + e + ' also types é), and nothing needs to be held down.
It works without any third-party software:
- A LaunchAgent runs
hidutilat login to remap right alt to F13, a key nothing on macOS uses. ~/Library/KeyBindings/DefaultKeyBinding.dicttells macOS what to type after F13. It also makes Home and End move to the start and end of the line.
./install.shThen restart any open apps so they pick up the key bindings. Running it again reinstalls, e.g. after changing the bindings.
To remove everything:
./uninstall.shBoth scripts replace the whole hidutil key mapping and the whole
DefaultKeyBinding.dict, so any other remaps or key bindings you had there are
lost.
For uppercase, type the letter with Shift: alt + ' + E types É.
| Keys | Result | Uppercase |
|---|---|---|
alt + ' + e |
é | É |
alt + ^ + a, or alt + 6 + a |
â | Â |
alt + ^ + e, or alt + 6 + e |
ê | Ê |
alt + ^ + i, or alt + 6 + i |
î | Î |
alt + ^ + o, or alt + 6 + o |
ô | Ô |
alt + ^ + u, or alt + 6 + u |
û | Û |
alt + ` + a |
à | À |
alt + ` + e |
è | È |
alt + ` + i |
ì | Ì |
alt + ` + o |
ò | Ò |
alt + ` + u |
ù | Ù |
alt + " + a |
ä | Ä |
alt + " + e |
ë | Ë |
alt + " + i |
ï | Ï |
alt + " + o |
ö | Ö |
alt + " + u |
ü | Ü |
alt + ~ + n, or alt + ` + n |
ñ | Ñ |
alt + , + c |
ç | Ç |
alt + a + e (in this order) |
æ | Æ |
alt + o + e (in this order) |
œ | Œ |
alt + o + / |
ø | Ø |
alt + s + s |
ß | |
alt + = + e, or alt + = + c |
€ | |
alt + o + c |
© | |
alt + o + r |
® | |
alt + o + o |
° | |
alt + . + . + . |
… | |
alt + - + - |
— | |
alt + < + < |
« | |
alt + > + > |
» | |
alt + = + / |
≠ | |
alt + < + = |
≤ | |
alt + > + = |
≥ | |
alt + ^ + 2 |
² | |
alt + ^ + 3 |
³ | |
alt + - + > |
→ | |
alt + < + - |
← |
| Keys | Action | macOS default |
|---|---|---|
| Home | Start of line | Scroll to top of document |
| End | End of line | Scroll to bottom of document |
| Shift + Home | Select to start of line | Select to start of document |
| Shift + End | Select to end of line | Select to end of document |
On a Mac laptop, Home and End are Fn + ← and Fn + →.
Sequences and key bindings live in bindings.yml. After editing it, regenerate the key bindings file and reinstall:
bin/generate_bindings.rb > Library/KeyBindings/DefaultKeyBinding.dict
./install.shThe generator uses the Ruby that ships with macOS. It adds uppercase sequences
automatically, and stops with an error if a sequence is the start of another
(e.g. -- and ---) or two sequences produce different results.
Key bindings only work in apps built on the native macOS text system, such as TextEdit, Mail, Notes and Safari. They don't work in Electron apps (VS Code, Slack, Discord), JetBrains IDEs, and some other cross-platform apps.