There is one drawback to this approach: since we have placed the script in iTunes's own scripts folder, we can only access it from iTunes's menu bar. Consequently, the keyboard shortcut will also work only if iTunes is the active application.
To make the script accessible even when iTunes is in the background, we need to move the script file to the User Scripts folder (see "Where to store AppleScript files on your Mac") so it shows up in the Script Menu. Let's do that now: choose "Open Scripts Folder" from iTunes's script menu, choose "Open Scripts Folder > Open User Scripts Folder" from the OS X Script Menu, and move the file "Pause iTunes.scpt" from the former to the latter.
Please don't head over to the Keyboard & Mouse preferences just yet, because there is a peculiarity about the OS X Script Menu: this menu is controlled by System Events, a faceless background application that does not show up in the Application menu in the Keyboard Shortcut preferences. Consequently, this means that it is not possible to assign keyboard shortcuts to any scripts listed in OS X's Script Menu. Then again, it is possible, if we replace the built-in Script Menu with Red Sweater Software's FastScripts.
A Better Script Menu: FastScripts
FastScripts is a vastly improved version of the Script Menu. It uses the same locations to search for AppleScript files to display, but lets you assign keyboard shortcuts to these scripts (Figure 4).
Figure 4. FastScripts script menu, including some items with keyboard shortcuts.
Adding a keyboard shortcut to any of the scripts listed in FastScripts is superbly Mac-like: hold down the Command key and click on a script in the menu, and FastScripts will open its Script Shortcuts preferences—which shows a complete, hierarchical list of all script files found in the User and Library Scripts folders—selecting the proper entry. Type the desired key combination, and you're all set (see Figure 5).
Figure 5. FastScripts compiles a list of AppleScript files for painlessly adding a keyboard shortcut.
To change a shortcut, double-click on an entry in the Script Shortcuts list and type in a new key combination. If you would like to remove a keyboard shortcut altogether, double-click the entry and press the Delete key. Note, by the way, that—unlike the approach via OS X's Keyboard & Mouse preferences—there is no need to restart FastScripts: the keyboard shortcuts show up, and work, right away.
In addition to supporting keyboard shortcuts, FastScripts also lists recently launched scripts, shows script execution errors in a separate window (whereas, in Script Menu, buggy scripts may fail silently), and, best of all, FastScripts is an application that is itself scriptable. It has an extensive AppleScript Dictionary, so you can do nifty things like this:
tell application "FastScripts" to invoke (the script items whose name is "Pause iTunes")