[macvoiceover] Re: Add Keyboard Shortcuts From The Command Line

  • From: vashaun jones <vashaun.jones@xxxxxxxxx>
  • To: macvoiceover@xxxxxxxxxxxxx
  • Date: Wed, 14 May 2008 17:07:36 -0400

This is great and goes along with my Terminal podcast. Thanks for posting!

On May 14, 2008, at 4:52 PM, David Truong wrote:

Taken from:
http://www.mactipper.com/2008/02/add-keyboard-shortcuts-from-command.html

When I installed Leopard, I lost the functionality (for some odd reason) to
add keyboard shortcuts via the System Preferences "Keyboard & Mouse"
preference
pane. Well, here's a way to add keyboard shortcuts through the command line.

By using the template:

defaults write com.apple.App NSUserKeyEquivalents '{"Menu Item"="@n";}'

we can make a keyboard shortcut for a lot of different apps. We change the com.apple.App to the name of the application (case sensitive) and we use
these
symbols near the end to represent the modifier keys that one would press:

• @ = Command
• $ = Shift
• ~ = Option
• ^ = Control

So, to make a keyboard shortcut in Mail to show the Photo Browser, you would
first quit Mail, then type into the Terminal:

defaults write com.apple.Mail NSUserKeyEquivalents '{"Photo
Browser"="@$p";}'

Which means that when we open up mail again, we can hit Cmd-Shift-P to open
the photo browser.

As another example, if, in Safari, you wanted to make the Google Search box
selectable with Cmd-K (the firefox default) and you wanted "Reopen All
Windows
From Last Session" to be Cmd-Shift-R, you could use:

defaults write com.apple.Safari NSUserKeyEquivalents '{"Google
Search…"="@k";"Reopen All Windows From Last Session"="@$r";}'

Note that you have to have a ; between the two terms and at the end of the
{}.

Finally, to remove a command edit (change Cmd-K back to Cmd-Option-F in Safari) simply replace the "@k" in the previously given command to "" and
get rid
of the "Reopen...ion"="@$r"; so that you end up with:

defaults write com.apple.Safari NSUserKeyEquivalents '{"Google
Search…"="";}'

Note, however, that the ... in "Google Search..." is actually an elipsis
which is typed using Alt-;.

As a final comment, to add a keyboard shortcut for every application, you
would use:

defaults write NSGlobalDomain NSUserKeyEquivalents '{"Send
Selection"="@~$i";}'

and obviously replace the "Send Selection" with your command and the "@~$i" with the shortcut. BTW, the given command will set the "Send Selection" item in the App_Name>Services>Mail> menu to Cmd-Option-Shift-i so that you can
select some text and pop it into an email with a simple shortcut.

Well, that's all for now. Thanks for reading and come back on Sunday for
more Mac tips from The MacTipper Blog!


Click on the link below to go to our homepage.
http://www.icanworkthisthing.com

Manage your subscription by using the web interface on the link below.
//www.freelists.org/list/macvoiceover

Users can subscribe to this list by sending email to
macvoiceover-request@xxxxxxxxxxxxx
with 'subscribe' in the Subject field OR by logging into the Web
interface at //www.freelists.org/list/macvoiceover



Click on the link below to go to our homepage.
http://www.icanworkthisthing.com

Manage your subscription by using the web interface on the link below.
//www.freelists.org/list/macvoiceover

Users can subscribe to this list by sending email to
 macvoiceover-request@xxxxxxxxxxxxx
with 'subscribe' in the Subject field OR by logging into the Web
interface at //www.freelists.org/list/macvoiceover

Other related posts: