Assigning command-F to the search feature in iTunes with Keyboard Maestro

Posted by Pierre Igot in: iTunes
June 1st, 2010 • 10:41 am

As far as I can tell, iTunes has no built-in shortcut to enter its “Search” field in the toolbar:

iTunes search field

There is also no menu command for it anywhere in the iTunes menu bar.

If you want to use the keyboard to enter this “Search” field without having to use the mouse, the only built-in option is to cycle through all available controls with the Tab key.

However, if, like me, you have Mac OS X’s “Full Keyboard Access” feature (in the “Keyboard Shortcuts” tab in the “Keyboard” preference pane in System Preferences) turned on, in order to be able access not just the main controls, but all available controls with the Tab key, then accessing the “Search” field in iTunes with the Tab key can be quite frustrating, because, depending on where the keyboard focus currently is, you might need an awful lot of Tab keystrokes before you can finally reach the “Search” field.

In addition, the blue halo that is used to indicate on which control the focus currently is is sometimes barely visible in the vast expanse of the main iTunes window, which makes it quite easy to lose track of it.

So, is there a solution to this?

Yes, but it involves using a third-party tool such as Keyboard Maestro.

Since there is no menu command for accessing the “Search” field in the iTunes menu bar, you cannot use Mac OS X’s “Keyboard Shortcuts” feature to assign a keyboard shortcut to such a command. (There is a “Search…” command in iTunes’s “Store” menu, but it’s for doing searches in the iTunes Store, not in your local library.)

The fact that there is no menu command also means that you cannot use the “Select a Menu Item” action in Keyboard Maestro. Instead, you have to use Keyboard Maestro’s ability to control the user interface by simulating mouse clicks.

More specifically, you have to use the “Click Mouse” action, which can simulate a mouse click anywhere in the front window using coordinates that are calculated relatively to any of the four corners of the window. Since the “Search” field in iTunes is near the top right corner of the window (and the iTunes toolbar is not customizable, so that will always remain true), all you need to do is to instruct Keyboard Maestro to simulate a click with the mouse at a point such as (-50,41) relative to the front window’s top right corner. (The exact coordinates can vary within a small range both vertically and horizontally.)

Then you can add a second step instructing Keyboard Maestro to simulate the command-A shortcut. This will ensure that, if there is already something in the “Search” field, after clicking on the field, the macro will automatically select the text, so that you can just type something new over it.

Finally, all you have to do is assign the command-F hot key trigger to your macro. (command-F is already used in the iTunes menu bar for the “Full Screen” option in the “View” menu, but this menu item is disabled unless you are running the visualizer. And if you really need a shortcut for this “Full Screen” option, you can create a separate macro for it with Keyboard Maestro and assign another hot key trigger to it. Alternatively, you can use something else as a trigger for the search macro.)

Et voilà. You can now use command-F in iTunes as a shortcut to access its “Search” field in the toolbar.

[UPDATE: Well, it turns out that there is a built-in shortcut for the search field in iTunes, even though it’s not visible anywhere in the user interface: It’s command-option-F. The shortcut is listed in the “Keyboard Shortcuts” help feature in iTunes’s “Help” menu. I suppose I should have checked there first. Thanks to Betalogue reader Patrick M. and others for pointing it out to me. Still, the above tip remains useful if you want to assign a shortcut other than the default one provided by iTunes, and especially if you’d rather use the standard command-F shortcut.]

Comments are closed.