If you have a MacBook, MacBook Pro or are using Apple’s Aluminum Keyboard, you can control some commonly used functions, such as iTunes playback, volume, Dashboard etc., directly with the function keys at the top of the keyboard. These keys actually have dual functionality: either they control the functions mentioned above, or they act as ordinary function keys (F1-F19) and trigger whatever action the current application has mapped to them.
They way you switch between these two modes is by using the fn key on your keyboard. By pressing and holding the fn key and then pressing a function key, you trigger the alternate function. Which function is the default function and which is the alternate function triggered by the fn key, is set in System Preferences → Keyboard & Mouse (see the screenshot).
Sometimes it would be handy to be able to switch the function keys mode without the need to launch System Preferences. If you happen to run Windows in VMWare Fusion or Parallels, you might have noticed that many apps in Windows make use of the F-keys. Mac applications usually offer shortcuts based on pressing a letter or a number together with one or more modifier keys. On Windows the use of the keys F1-F20 is more common.
The problem is that when your Mac’s function keys are set to trigger the special functions instead of the F-keys by default, you have to press the fn key together with the appropriate function key. And if some command in a Windows application is triggered by Ctrl+F3, you’d need to press fn+Ctrl+F3. Due to the location of the fn-key, this can be quite difficult.
That said, a quick way to toggle the function key functionality would be handy. After searching around for a bit, I found a pretty easy way to achieve this via AppleScript.
How to toggle Fn keys with Applescript
What this AppleScript does is simply launch System Preferences and toggle the appropriate checkbox. It’s not instant, since System Preferences actually has to be launched and quit when the checkbox has been toggled. But it’s definitely more comfortable running this script from the script menu than doing it all by hand.
If you want to give this script a try, here’s what you need to do:
- Make sure you are using Mac OS X Leopard. The script wasn’t tested on Tiger or older and I don’t know if it would work.
- Download the AppleScript.
- Copy the script to [your user folder]/Library/Scripts.
- Launch AppleScript Utility from the Applications/AppleScript folder.
- In AppleScript Utility, activate the checkboxes Enable GUI Scripting and Show Script menu in menu bar.
That’s it. Now, whenever you need to quickly switch between the two modes of your keyboard’s function keys, simply select the script Toggle Function Keys from the system-wide script menu.
For even more convenience, check out Red Sweater Software’s FastScripts. It lets you assign keyboard shortcuts to scripts in your AppleScript menu.