Skip to content

Instantly share code, notes, and snippets.

@langolf
Last active February 18, 2021 16:52
Show Gist options
  • Save langolf/3e88e9892b4bf69c7ef283765df49af4 to your computer and use it in GitHub Desktop.
Save langolf/3e88e9892b4bf69c7ef283765df49af4 to your computer and use it in GitHub Desktop.
Disable letter keybinding with option

Save the following to ~/Library/KeyBindings/DefaultKeyBinding.dict (create if necessary).

{ "~a" = (); "~b" = (); "~c" = (); "~d" = (); "~e" = (); "~f" = (); "~g" = (); "~h" = (); "~i" = (); "~j" = (); "~k" = (); "~l" = (); "~m" = (); "~n" = (); "~o" = (); "~p" = (); "~q" = (); "~r" = (); "~s" = (); "~t" = (); "~u" = (); "~v" = (); "~w" = (); "~x" = (); "~y" = (); "~z" = (); } This disables all the ⌥ combinations. Restart apps to take effect.

The DefaultKeyBinding.dict above is an old-style property list1, defining key-value pairs using the syntax { key = value }. In this case, the keys are the key combinations to activate the method in the value.

Standard dictionary key symbols are used: ~ alt, ^ control, $ shift, @ command. Therefore ~a means ⌥A (alt-A) and ^$1 would be ⌃⇧1 (control-shift-1).

The value for each of the keys is set to ()—empty parentheses without a method. As DefaultKeyBinding.dict overrides /S*/L*/Fr*/AppKit.*/R*/StandardKeyBinding.dict, the shortcut is defined to be without method and therefore does nothing. It's preferable to create your own key bindings file like this rather than editing the system one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment