Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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 :)

Licensed under: CC-BY-SA with attribution
Not affiliated with apple.stackexchange
scroll top