Bob Kåres homepage

Compose key for OSX

Being a coder I prefer the symbol layout on US keyboards to the horridness of Norwegian keyboards (you have to almost break your fingers to get curly braces). However I also sometimes need special characters like the ø in my name or proper quotation marks, and for this compose key is a really nice solution.

On linux it's trivial to get it working: setxkbmap -option compose:menu

OSX is a different beast though, with no built-in support for it. However it's input system is really very flexible, and with some initial pointers from a thread I found “Customizing the Cocoa Text System” which contained most of what I needed to know to hack a compose key into OSX. reads an compose key table like this one, looks the keysyms up in X11::Keysyms and writes a keybindings file that you can put in ~/Library/KeyBindings/DefaultKeyBinding.dict.

To make sure it doesn't do too much interesting to my keyboard the script filters out anything sequence from the input file that doesn't start with <Multi_key>, and all dead keys.

I would have loved to use the right option key or something for compose, but unfortunately it seems modifier keys are handled quite differently from normal keys, so I put it on F13. If you have a better key available to you it's defined as a constant at the top of the script.

After putting the file in place it should take effect the next time you start any Cocoa application, except for which needs one more tweak: Preferences → Settings → Keyboard (Yay! typing fancy arrows!) and delete any binding set up for you compose key

Here's the script and the output file:, DefaultKeyBinding.dict