Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Add a keyboard shortcut to any Services menu item System

You can easily add a keyboard shortcut to any item in the Services menu. The problem is finding a shortcut that is not already being used by something in the System or one of the applications you use. To add a keyboard shortcut to an item in the services menu, follow these steps...

Read the rest of the article for the step by step instructions.

[robg adds: Bandwidth warning: I added three images to this tutorial to make it clearer, so the remainder of this article is about 50k in size. Also, we ran something similar on removing shortcut keys from services, but this tutorial goes into much greater detail...]

To add a keyboard shortcut to an item in the services menu:

  1. Determine the item you want to add a shortcut for and then determine if the shortcut you want to use is already being used elsewhere.

  2. Locate the application that contains the shortcut you want to add too. Control-click on application icon and select "Show Package Contents".

  3. Navigate to the Contents directory and open the file Info.plist with a text editor, or preferably the PropertlyList Editor.

    If using PropertyList Editor:

    Click the triangle next to Root and then scroll down and locate the NSServices entry. Inside that entry you should see each item that appears in the services menu for that application, identifed by a number (0 = first item, 1 = second item, etc.). Locate the one for which you want to add a keyboard shortcut. Click the expansion triangle to reveal the listing underneath it. It should contain something like this:

    You will be adding a new child under the numeric heading for the service item you want to modify. Make sure the numeric heading (in example above it is 0) is highlighted and click the Add Child button at the top of the window. Select the new entry that appears and enter NSKeyEquivalent in the first field and select Dictionary in the second field. So now it should look like this:

    Highlight the "NSKeyEquivalent" item and click the "Add Child" button again to add a new entry under it (note: the disclosure triangle must be pointing down, otherwise you'll see "New Sibling" instead of "Add Child"). Select the new entry and enter "default" in the first field and select "String" in the second field. Now enter a single letter or character in the third field. This will be your new keyboard shortcut along with command+shift. So if you enter "Z" in the third field your keyboard shortcut for that menu item is command+shift+Z. You should now have something like this:

    Save the Info.plist and close.

    If using a Text Editor robg adds: Note that the screenshots above are from TextEdit's services menu; the following example is from BBEdit, so they don't agree with each other -- that's my fault when creating the screenshots

    Search for "NSServices" in the file. Locate the item you want to modify and change as shown below (read above for details as necessary).

    Before

    <dict>
      <key>NSMenuItem</key>
        <dict>
          <key>default</key>
          <string>BBEdit/Open Selection</string>
        </dict>
      <key>NSMessage</key>
        <string>openSelection</string>
      <key>NSPortName</key>
        <string>BBEdit</string>
      <key>NSSendTypes</key>
        <array>
          <string>NSStringPboardType</string>
          <string>TEXT</string>
          <string>utxt</string>
      </array>
    
    After
    <dict>
      <key>NSKeyEquivalent</key>      <==== add
        <dict>                        <==== add
          <key>default</key>          <==== add
          <string>B</string>          <==== add
        </dict>                       <==== add
      <key>NSMenuItem</key>
        <dict>
          <key>default</key>
          <string>BBEdit/Open Selection</string>
        </dict>
      <key>NSMessage</key>
        <string>openSelection</string>
      <key>NSPortName</key>
        <string>BBEdit</string>
      <key>NSSendTypes</key>
        <array>
          <string>NSStringPboardType</string>
          <string>TEXT</string>
          <string>utxt</string>
      </array>
    
    Save the Info.plist and close.

  4. You will need to logout and log back in again to see your changes in the Services menu.
Notes
  • According to the Apple documentation on "Service" properties, you don't really have a choice of command keys involved. The keyboard shortcut always requires Command and Shift plus a single letter. Although I did notice that the PGP services menu item has single command plus letter and character shortcuts. Does anyone know how they did that? The only difference I see in their plist is that they are using numerals instead of letters for shortcuts.

  • The odds are fairly high that you will accidently choose a shortcut that is already being used. If you do not get the desired results with this process - double check to make sure something else hasn't already claimed that key. Then you can decide if you want to turn that off in favour of yours or pick another key.
    •    
  • Currently 2.40 / 5
  You rated: 1 / 5 (5 votes cast)
 
[20,516 views]  

Add a keyboard shortcut to any Services menu item | 14 comments | Create New Account
Click here to return to the 'Add a keyboard shortcut to any Services menu item' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Add a keyboard shortcut to any Services menu item
Authored by: Anonymous on Apr 08, '03 11:04:43AM

This is just what i've been looking for since the services menu appeared a long time ago! Now i can save selections of text into textedit with one key-command!!

thanks-!!



[ Reply to This | # ]
Add a keyboard shortcut to any Services menu item
Authored by: bluehz on Apr 08, '03 11:39:50AM

Yes - the one service cmd key I wanted was saving a selection to BBEdit. I searched and thought I finally found the "key" to use - cmd+shift+B.... nope... turns out Mail uses that one. So the big challenge here is finding and unused cmd key sequence. I wish there was a way to print out a chart of EVERY cmd key used in every app (or at least a selected subset) on your machine - now THAT would be useful!

In my case I just changed the "B" in Mail as I will use the Save to BBEdit more than Add BCC. Its robbing Peter to pay Paul or however that saying goes. I used an app called Rekey to change the shortcut in Mail - its the only way I could figure out how to do it. If you use Rekey - its finicky as hell! The menu name MUST MATCH EXACTLY (case matters) and there is no way to remove a shortcut for an item. At least I was unable to - every time I trie dto remove an item (untick all the boxes and remove the ltr) Rekey would crash instantly. So I ended up just chagning the key cmd (Although I would have preferred to remove it).



[ Reply to This | # ]
Add a keyboard shortcut to any Services menu item
Authored by: mici on Jun 17, '05 06:24:11PM

with developer tools intalled, you can edit Mail interface .nib file with Interface Builder. just open the app package contents, look up the MailViewer.nib file and edit (WYSIWYG) menu item shortcuts to your liking.



[ Reply to This | # ]
Remove a app's services
Authored by: englabenny on Apr 08, '03 01:03:39PM

I read someplace it was time to tidy up the services menu by removing certain services. I, for example, never use Bluetooth. It was said you did this by doing something in the info.plist. Will removing the entire NSService branch in the plist do the trick?

Off-topic:
WHy does my camino no longer support services? It neither responds to them, as well as the service menu in Cam is all gray. :(



[ Reply to This | # ]
Remove a app's services
Authored by: robg on Apr 08, '03 02:57:43PM
The hint you're referring to is linked in my robg adds bit at the bottom of the intro...

-rob.

[ Reply to This | # ]
Remove a app's services
Authored by: g3ski on Jun 12, '08 03:11:02PM
http://www.manytricks.com/servicescrubber/

use this donation-ware to cleanup the services menu

[ Reply to This | # ]
Add a keyboard shortcut to any Services menu item
Authored by: nosaj56 on Apr 08, '03 05:28:36PM

This won't be needed soon. One of the best Mac Shareware companies will be coming out with a program that will make changing any keyboard shortcuts, including shortcuts in the Services menu, very easy. Just wait and see. :D



[ Reply to This | # ]
Must be...
Authored by: robg on Apr 08, '03 07:45:10PM
... Menu Master from Unsanity. I think it was just announced today; I haven't tried it yet...

-rob.

[ Reply to This | # ]
Must be...
Authored by: bluehz on Apr 09, '03 01:10:34AM

IMHO - until Unsanity stops using Application Enhancer (APE) or admits that it causes problems and solves the problems - I would highly recommend against MenuMaster.



[ Reply to This | # ]
Way to get path
Authored by: englabenny on Apr 09, '03 10:37:12AM

I found using this tip to set "open selection in TextEdit" to cmd-shift-T, i can quickly get the path to any file in Finder. Just selecting a file in Finder and hitting the set shortcut opens me a new TE window with the file path inserted.

Some people might argue that this is not quick and Terminal can do the same, but sometimes you need a file path anotherplace than in Term. And this is also just a bonus to a useful hint.



[ Reply to This | # ]
Way to get path
Authored by: HuntingBears on Jul 16, '03 04:58:46PM

The nice people at Scotland Software have written a great Services menu item that works better and doesn't require any extra steps!

http://www.scotlandsoftware.com/products/systemservices/



[ Reply to This | # ]
Add a keyboard shortcut to any Services menu item
Authored by: jceaser on Feb 14, '07 07:43:39PM

From a service that I have just created for my own personal uses, you only need shift-command if you enter a capital letter in to the .plist file. shift-command-m is the same way of saying command-M. As for numbers not requiring the use of a shift key, this can be explained with command-! which is of course the same as to command-shift-1.



[ Reply to This | # ]
Add a keyboard shortcut to any Services menu item
Authored by: marcsnir on Jul 24, '08 12:59:27PM
Do not use this method on Mac OS 10.5 for "signed" mac applications.

The outcome is that the applications are detached from the keychain. I tried to associate a keyboard shortcut with mail, and now I have to enter my password whenever I start mail.

See: http://www.manytricks.com/blog/?id=30

[ Reply to This | # ]

Add a keyboard shortcut to any Services menu item
Authored by: marcsnir on Jul 24, '08 01:05:20PM
Do not use this method on Mac OS 10.5 for "signed" applications

the change in info.plist cause them to be detached from the keychain. I tried to associate a keyboard shortcut with Mail and now I have to enter my password whenever I start Mail.

See: http://www.manytricks.com/blog/?id=30

[ Reply to This | # ]