macOS compose key



Generates key binding dictionaries using a facility built into macOS, described at

Comes with a companion utility called gen-compose-convert that can accept X compose files as input. Usage:

gen-compose-convert xcompose ./path/to/Compose --keep-comments > xcompose.yaml

Use the output of the above command as input for gen-compose. Usage:

gen-compose xcompose.yaml > ~/Library/KeyBindings/DefaultKeyBinding.dict

This generates a key binding dictionary that uses the non-US backslash character (§) as the first character in the chain. What's missing is a way to directly type § on a US English keyboard.


Since macOS 10.12 Sierra, there has been an ability to do specify simple key re-mappings using the hidutil utility. This functionality is described at

Command to check current key mappings:

hidutil property --get "UserKeyMapping"

Command to map right Option key to §:

hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x7000000E6,"HIDKeyboardModifierMappingDst":0x700000064}]}'

Auto-run at startup

Effects of hidutil do not persist across reboots. In order to have the key remapping apply automatically, the command needs to run at startup. One method of doing so is by making a LaunchAgent.

Save the following as ~/Library/LaunchAgents/local.RemapRightOptionToNonUsBackslash.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">

You'll only receive email when they publish something new.

More from 1559
All posts