Using keyboard expansions...what governs how they work?


The title of this posting doesn’t really explain what I am asking, but I wasn’t really sure how to phrase this succinctly.

For those who have listed to the Automators episode with Brett Terpstra (yes, I know there’s a separate forum for that podcast, bear with me…):

Brett talked about using keyboard bindings to execute a variety of command, macros, actions, etc. Probably most people on this forum have also created keyboard shortcuts to do various kinds of actions through other mechanisms, such as TextExpander. I have snippets in both Alfred and Keyboard Maestro, generally selecting the utility that make it easiest to accomplish a particular effect. For example, KM makes it easiest to restrict a given keyboard expansion to a particular application, but I do most of my snippets in Alfred as there have been concerns raised in the past about KM’s ability to handle large numbers of keyboard expansions as that is not something the app was particularly designed to do.

So I am wondering, from a technical standpoint, where do keybindings fit into this process? WHy would I create a keybinding (short of wanting one key to do something different then usual, like making CapsLock simulate shift-option-control-command as Breet has done), vs using a snippet in Alfred or TextExpand or trigger in KM?

Do these different mechanisms work at different levels in MacOS? For instance, Alfred and KM both tie into accessibility framework to monitor keystrokes, and I assume TextExpander does the same. Do key bindings work at a lower level in the OS? What if I assign the same trigger in Alfred, KM, TE, and as a keybinding? Do all 4 actions happen?

Just curious and wondered if anyone had the technical knowledge to clarify this for me, as I am curious, and perhaps understanding the technical underpinnings would help me to figure out how to leverage the different approaches for different uses.



A quick search found this:

Key Bindings is a feature of Mac OS X’s [Cocoa] Text Input system…

As to why one would want to change the default key bindings, I imagine it comes down to a combination of personal preferences and muscle memory. Terminal (shell) users, for example, get used to the particular way their keyboards work and might want their keyboard to work similarly outside the shell. For example, some shells support emacs-like command line editing, and it seems reasonable that some users might want emacs-like key bindings in their word processor of choice.