A tutorial on re-mapping dead keys on macOS keyboard layouts
Depending on the macOS keyboard layout you’re using, you might have “dead keys”. A dead key represents a symbol that isn’t a full character and therefore isn’t immediately inserted into the text when typed. Examples of dead keys are ^
, `
and ~
. For instance, when typing `
followed by a
, macOS will insert à
instead.
For programmers, this behavior is often undesirable. For example, the tilde (~
) is a useful shortcut for the $HOME
shell variable, and the backtick (`
) is used for template literals in JavaScript. Therefore, if you’re not using the symbols in your language, it might be preferable if these characters were inserted immediately when typed.
Fortunately, reconfiguring your keyboard layout to remove these dead keys is relatively easy. The Ukelele app can help you with this task:
- Download and install Ukelele from its website or using
brew cask install ukelele
. - Open the Ukelele app.
- In the application menu, select
File
→New From Current Input Source
. This will detect your keyboard layout and create a copy that you can modify. - In the main window, Ukelele displays your layout with the dead keys highlighted in red. Right-click each of your dead keys, select the corresponding modifier key if necessary (e.g. the shift or option key) and enter the key’s value at the bottom of the dialog. This will change the key’s behavior to insert the symbol right away.
- Once you’ve re-mapped all dead keys, save your keyboard layout and copy it to the
~/Library/Keyboard Layouts
directory. - Reboot your Mac.
- Open the System Preferences and navigate to
Keyboard
→Input Sources
→+
. Your custom keyboard layout can be found under the language it’s based on. You can now add your new keyboard layout and activate it from the menu bar.