I know you can toggle this option on and off in the System Preferences screen for 'keyboard' but I'd like to know if I can do it via a shortcut as I do it all the time.

link|improve this question
feedback

1 Answer

To make the following work, you need to Enable access for assistive devices in System Preferences » Universal Access.


Open Automator, select Service and choose that the service receives no input (near the top).

Double-click Run AppleScript in the Utilities category of the library. Replace the default code snippet of the newly created action with the following:

tell application "System Preferences"
    set current pane to pane id "com.apple.preference.keyboard"
    tell application "System Events"
        tell process "System Preferences"
            click checkbox "Use all F1, F2, etc. keys as standard function keys" of tab group 1 of window "Keyboard"
        end tell
    end tell
    quit
end tell

System Preferences will launch, but it will not be displayed and will quit immediately after toggling the setting.

Press Command-S to save, give it the name e.g. Toggle Fn. Result:

enter image description here


Go to System Preferences » Keyboard » Keyboard Shortcuts » Services to assign a keyboard shortcut for this Service.

link|improve this answer
If System Preferences is already running when you perform this command, it will quit. The code to prevent this would have bloated this answer. – Daniel Beck Feb 9 '11 at 18:39
The question is tagged osx-snow-leopard, which this answer seems to require. I don't think I can make a service in OS X 10.5 judging from what I can see in front of me compared to gigaom.com/apple/… – Philip Durbin Feb 14 '11 at 1:53
@Philip I don't recall how Services worked in 10.5, but an Automator-created service is just an Automator workflow saved to ~/Library/Services. Maybe you can replicate this manually? To configure the Services menu, use ServiceScrubber. – Daniel Beck Feb 14 '11 at 7:16
this works on 10.6 but for some reason my keyboard shortcut kept failing or firing when I didn't want it to. so i switched to calling it from the command line with osascript based on stackoverflow.com/questions/3446128/… – Philip Durbin May 11 '11 at 13:48
@Philip You can always enable the AppleScript menu and store the code as scpt file in ~/Library/Scripts and call from the menu bar. Using the 3rd party FastScripts, you can assign a keyboard shortcut. – Daniel Beck May 11 '11 at 21:06
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.