Customizing global keyboard shortcuts on macOS to insert unicode characters
I like text. I write a lot of it in different forms. But one thing that has always bothered me is the emoji picker. It’s gotten better over the years, but it feels way too slow. Triggering control+command+space
is a reflex now, but still requires scrolling, searching, and double-clicking to insert a single character. When you’re used to your hands not leaving the keyboard, feels like an eternity to hunt for 👍.
At the same time on macOS, there is a whole hidden layer of keyboard shortcuts for inserting various unicode symbols. If you’re not familiar, typing option
or option+shift
and any key inserts a special unicode character. For example, type option+shift+k
and you get . You can find a full rundown of what they all are on this TidBITS post . I’ll never use 99% of those characters though, and wanted to customize them for my own needs, but couldn’t find a built-in way. I reached out on twitter and got a helpful reply from Brett Terpstra with the answer.
Enter DefaultKeyBinding.dict
The short version is you can customize them with a file named DefaultKeyBinding.dict
stored in ~/Library/KeyBindings/
. The syntax is a bit odd unless you’ve done some Cocoa programming, in which case it’s still odd, but slightly more familiar. The most official documentation I could find on developer.apple.com was Text System Defaults and Key Bindings, but below is a condensed version with a few examples for anyone else out there that just wants to do some quick shortcuts to insert single characters like me.
{
// ~ = Option
// $ = Shift
"~v" = (insertText:, "✓");
"~b" = (insertText:, "●");
"~c" = (insertText:, "⌘");
"~t" = (insertText:, "👍");
"$~T" = (insertText:, "👎");
}
- Copy the text above
- Change as desired for your needs
- Make the
~/Library/KeyBindings
directory if it doesn’t exist - Save the above text to
~/Library/KeyBindings/DefaultKeyBinding.dict
- Quit and restart any open apps to take effect
- Voila! You can now insert any characters you want in any text field with a simple keyboard shortcut. like
option+b
to insert ●
My goal was inserting single characters, but you can insert any string you want including full words. If you want to go deeper, there is a ton you can do here including complex text commands and should read more on Brett’s repo.