I want to change one of my keys on my keyboard to a Compose key so I can easily type common accents or characters, e.g.: Compose+e+' -> é.

Is there a setting I can change or a program I can install to add this feature? For instance, I would like to use Caps Lock as Compose.


5 Answers 5


I wrote a complete article explaining how to set up a real compose key (ie. Right Option + ' + eé for instance), using a combination of KeyRemap4MacBook and specific Cocoa input rules.

Step 1: choose a Compose key

Choose the Compose key so that it is easily accessible but does not prevent you from doing anything you ordinarily do. I use the Right Option key as my Compose key. I already have a Left Option key so the right one is a bit useless to me. And it somehow matches the position of the Compose key on old Sun keyboards.

That would be Right Option on a Mac keyboard. I recommend that.

Step 2: remap the Compose key

The problem is that the Mac OS X keyboard preferences:

  • do not let you differentiate between Left Option and Right Option keys
  • only let you remap modifier keys to another modifier key (or to nothing)

Fortunately, there is KeyRemap4MacBook that lets you do very low level things with your keyboard. Install it.

We will now remap our compose key to something that the next layer will understand. I chose Shift Control F13 for that. It is very unlikely you will need that key combination.

In the file ~/Library/Application Support/KeyRemap4MacBook/private.xml put the following:

<?xml version="1.0"?>
    <name>Send Shift-Ctrl-F13 for Right Option</name>
    <autogen>--KeyToKey-- KeyCode::OPTION_R,
                          KeyCode::F13, ModifierFlag::SHIFT_L
                                      | ModifierFlag::CONTROL_L

Finally, from the System Preferences, open the KeyRemap4MacBook settings and click on the ReloadXML button. Then activate the new option.

Step 3: create compose bindings

The last step is the creation of the actual bindings. I chose to import the rules from /usr/share/X11/locale/en_US.UTF-8/Compose on my Debian system.

Bob Kåres wrote a script that lets you convert X11 compose rules into Cocoa key bindings.

Either convert a Compose file of your own using Bob’s script, or download my DefaultKeyBinding.dict from the article. Save it in ~/Library/KeyBindings/DefaultKeyBinding.dict.

Be careful: by default Bob’s script uses F13 instead of Shift Ctrl F13 so in DefaultKeyBinding.dict you need to change:




If for some reason you decided to go for another combination, check out this article by Xah Lee to find out the proper syntax.

  • 1
    The content of the link looks like a great solution to this problem, but answers on Ask Different need to be more than just a link. It's okay to include a link, but please summarize or excerpt it in the answer. The idea is to make the answer stand alone.
    – Daniel
    Commented Jun 21, 2012 at 19:42
  • @DanielLawson sure, that makes sense; I'll update my answer. Commented Jun 21, 2012 at 20:39
  • There, I copied most of the article. I can do that, since I own it :-) Commented Jun 21, 2012 at 20:48
  • Truly awesome answer; +50 internets. (Seriously, I'm giving this one a bounty as soon as the system lets me)
    – Daniel
    Commented Jun 22, 2012 at 13:18
  • 1
    Glad you inlined the link, because it's now dead! (You may wish to update it if it's moved.)
    – wchargin
    Commented Feb 1, 2015 at 21:32

A "dead keys" feature similar to what you want already exists by default. To get the letter é, press Option ⌥+e, then e.

After pressing +e, you'll see a ´ character highlighted (it's yellow on my computer). Press any letter that will take that accent mark (this will vary based on your keyboard language, for EN-US it's é, ú, í, ó, and á) and you'll get the accented version of the letter. There are other accents possible: +` gives an agrave accent (```), +e gives an acute accent (´), +u gives a diaeresis/umlaut (¨), +i gives a circumflex accent (ˆ), and +n gives a tilde (˜). Non-US keyboard layouts (in particular Welsh) have more accents and allow more letters for the same accents. The Keyboard Viewer is useful to help figure out what combinations are currently supported on your layout.

If you are on Lion, as @djacobson mentioned, you can hold down some letters to see a variety of accented options for that letter.

  • if you use a different keyboard layout, it may not be ⌥+e. To see which one it is, open Keyboard Viewer (from the language tray icon) and press . The keys shown in yellow denote compositional characters Commented Sep 28, 2017 at 20:11
  • 3
    -1 You are simply describing macOS' built-in input method for diacritics and other "extra" characters. This is not the same thing as a (unified) compose key.
    – Lexible
    Commented Sep 9, 2021 at 17:59
  • This method is missing really a lot of characters. I couldn't find how to enter letters like ą,į,ū,ų,ė,ę,č,š,ž
    – Ski
    Commented Jan 18, 2022 at 11:23
  • @Ski To have the others you mention, you use the input source called ABC Extended. Commented Aug 24, 2023 at 14:50

Compose key on dedicated keyboard layout

I have written U.S. custom, a keyboard layout that implements the compose key.

On Mac OS X, there are two ways of implementing the compose key: Either with can be implemented either with the Cocoa text system (as already described in Sam Hocevar's most helpful answer) or with a dedicated keyboard layout. Both methods have their pros and cons:

  • A compose key implementation with the Cocoa text system will work independently of the chosen keyboard layout. The Cocoa text system settings in the DefaultKeyBinding.dict file are, by comparison, easily modified.
  • A compose key implementation with a keyboard layout will work all over the OS in any application, not just in Cocoa applications. It can be switched on and off with the UI by selecting another keyboard layout. There is a visual feedback while typing the compose combination (which slightly changes the behaviour).

The installation of the keyboard layout is easy:

  1. Download and open uscustom.2012-08-28.zip.
  2. Move the files UScustom.keylayout and UScustom.icns to either of:
    • /Library/Keyboard Layouts/ (for all users)
    • ~/Library/Keyboard Layouts/ (just for you, no administrator privileges required)
  3. Activate the U.S. custom keyboard layout in the Input Sources tab of the Language & Text Preference Pane, so you can then select it from the input sources menu bar item – its icon shows a U.S. flag with a little C for “custom” or for “compose”: U.S. custom icon.

The compose key of the U.S. custom keyboard layout is mapped to two different keys:

  • There is a compose key at ISO § (that is the surplus key of an ISO keyboard; ISO keyboards are the ones where the return key is shaped like a turned capital letter L).
  • There is another compose key at Shift+Control+F13. This is the same mapping as chosen by Sam Hocevar, so if you want to remap the compose key to you right option key, then you can exactly follow the careful explanations described in his answer.

Assigning compose to capslock

If you want to assign compose to the capslock key (as in the original question), you need Takayama Fumihiko’s PCKeyboardHack in addition to KeyRemap4MacBook:

  1. Install PCKeyboardHack.
  2. Open the PCKeyboardHack preference pane.
  3. Check the Change Caps Lock checkbox.
  4. Doubleclick on the keycode of Change Caps Lock and enter 10 (ISO §).

This works with the U.S. custom keyboard layout compose key. In order to assign the Cocoa text system compose key (as carefully described by Sam Hocevar) to capslock, then you need another step:

With KeyRemap4MacBook, remap the ISO § to Shift+Control+F13 (or whereever your compose key is). To do so, follow the steps carefully explained by Sam Hocevar, but changing the code that is to be placed in ~/Library/Application Support/KeyRemap4MacBook/private.xml thisly:

<?xml version="1.0"?>
  <name>Send Shift-Ctrl-F13 for ISO Section</name>
    KeyCode::UK_SECTION, ModifierFlag::NONE,
    KeyCode::F13, ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L

If you want to remap one of your keys, take a look at KeyRemap4MacBook, which is referenced in this SU post. The documentation notes that Caps Lock can be remapped, and custom mappings are also supported.


This does turn out to be quite annoying.

I have just spent some time fossicking through all the various answers to this and have found a combination of things that is working for me nicely on Mac OS Ventura.

All details of this answer are on this Gist forked from a previous Gist answering this question, and are reproduced below.

How to get a real Compose key on OS X Ventura

1. Install the so-called "U.S. Custom" keyboard layout

This is just a "playground" custom keyboard layout for doing exactly what we're going to do, namely setting up a typical Linux style Compose key for an English keyboard.

As someone who isn't from the States, I personally don't love that this layout is called "U.S. Custom" but I suppose it's not too important.

  • Download the ZIP file here
  • Unzip the archive
  • Copy the files to ~/Library/Keyboard Layouts (note you can use Cmd+Shift+. to show the hidden ~/Library folder on Mac OS Finder if you like, saves you any terminal faffing)
  • You will eventually need to restart your operating system, but you can do this later

2. Install Karabiner Elements

Install Karabiner Elements.

Note Karabiner expects you to enable various things in System Preferences (such as background modules for the "non-userspace" stuff that Karabiner appears to do). I simply assumed this would be okay as I am not very interested in opsec.

3. Configure the Caps Lock key as your new Compose key

I always use Caps Lock for Compose, not Right Command or another key as per some of these guides, because hey, I don't use it for Caps Lock.

This blog post is a useful overall reference for this part, and for this topic in general.

  • Visit this online editor for "complex" Karabiner rules
  • The preset config at the link has a pre-loaded Compose Key configuration (which is from the blog post above)
  • Change the Compose Key, which is initially set to Right Command, to whatever you prefer
  • Click "SHARE" and it'll prompt you to fire up Karabiner Elements from your browser to import the setting
  • Don't forget to click "Enable" in Karabiner Elements Settings so as to actually fire up the imported Complex Rule

Note that what the imported Complex Rule actually does is spit out a Ctrl+Shift+F13 (ie a key combination you're highly unlikely to be using for anything else) when you hit your Compose Key, which can then be used by your overridden DefaultKeyBinding.dict to insert the actual Unicode sequences when you hit "dead key" combinations.

4. Set up the Compose Key bindings

If you explore this topic you'll notice that various people have written scripts to output this DefaultKeyBinding.dict file based on X11 configurations.

I use Compose heavily, but I really only use default settings, and I never run Perl or X11 these days, so I just downloaded a pre-cooked mapping file which can be obtained from this Gist file (again this is linked in the same blog post

  1. Create a user key bindings directory at ~/Library/KeyBindings (this doesn't exist by default)
  2. Download the (raw) Gist contents and save them to ~/Library/KeyBindings/DefaultKeyBinding.dict

5. Restart your machine and set your Input Source

Note that before any of this will work, you will need to select the "U.S. Custom" keyboard layout you installed.

  1. Open System Preferences, search "Input Sources", open the dialog, click the "+", select "Others" as your language, and select "U.S. Custom" from the available options.
  2. If you can't see the option, make sure you didn't forget to restart and that you put the files downloaded in section (1) above in the right location.
  3. Having added the "U.S. Custom" Input Source, select it as your current Input Source and click Done.

6. Test it works

My personal most used Compose combination might be the single character ellipsis, which is mapped to CapsLock,-,-,- and gives me … … … get it?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .