Some apps (e.g. Tweetbot) have single-key keyboard shortcuts.
However, when trying to set shortcuts in System Preferences, we’re not allowed to do the same. Is there a user-facing way of achieving this?
Some apps (e.g. Tweetbot) have single-key keyboard shortcuts.
However, when trying to set shortcuts in System Preferences, we’re not allowed to do the same. Is there a user-facing way of achieving this?
It is possible to do, both natively and easily. Mac OS X hints has a hint (also check Lri’s comment) on how to set up keyboard shortcuts from the command line. We can use this to create single-key shortcuts.
You’ll need to know the application’s bundle ID (unless you want to set global shortcuts, naturally). For special keys, @
is ⌘; ~
is ⌥; $
is ⇧; ^
is ctrl. You can also check other values.
I’ll use Tweetbot as an example, setting “New Tweet” to ⌥+N, and “Reply” (on the multi-shortcut example) to R.
For one-shortcut commands, you can use the form:
defaults write com.tapbots.TweetbotMac NSUserKeyEquivalents -dict-add "New Tweet" -string "~n"
For multi-shortcut commands, use the form:
defaults write com.tapbots.TweetbotMac NSUserKeyEquivalents '{
"New Tweet"="~n";
"Reply"="r";
}'
For system-wide shortcuts, use -g
, instead of a bundle ID.
I doubt that you can have a system wide single key shortcut to do something like a cut and paste for instance, if that's what you're asking. Doing so would cause the actions to be triggered when you're typing an email, for example.
Some apps allow that most probably because they're programmed so that the single key shortcuts are only detected in certain modes/interfaces. But I could be wrong about Tweetbot because I've never used it :)
This is likely too late to help in future, as it's broken in Ventura. Prior to Ventura you can generate a single-key shortcut by pressing Fn [character] in the Shortcuts pref pane.
For example, adding just an H
as shortcut to Safari Help by actually pressing Fn h in the entry box.
This produces
in the menu itself & works from a single key-press.
Fortunately for this kind of structure, if you're typing in a text area the shortcut is not triggered.