Jump to content

Toggle fn Key Behavior


Recommended Posts

Toggles behavior of function keys between standard and special features (e.g., volume, play/pause), as described here.

 

fnToggle_screen.png

 

Specifically, accomplishes the following when keyword "fn toggle" is entered:

  1. Choose System Preferences from the Apple menu.
  2. From the View menu choose Keyboard (or Keyboard & Mouse in Mac OS X v10.5.8 and earlier).
  3. Check / uncheck "Use all F1, F2, etc. keys as standard function keys"
    (Note: when checked, requires holding the fn key to press standard function keys, 
    when unchecked, does not require holding the fn key to press standard function keys)

fnToggle_keyboard_screen.jpg

 

Download workflow

 

 

Link to comment
  • 4 months later...

Thanks for this! Noticed one weird bug where the AS doesn't work if you are in the "Keyboard Shortcuts" tab.

 

For this to work a bit better edit Mike's script in the workflow thusly:

 

on alfred_script(q)

tell application "System Preferences"
    reveal anchor "keyboardTab" of 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

end alfred_script
This will 'reveal' the anchor of the pane even when it's not previously selected.
 
ALSO, thanks for the workflow Mike!
Edited by RodgerWW
Link to comment

The original version of Keyboard Pilot (https://itunes.apple.com/app/id402670023?mt=12) allowed you to set Fn key behavior for each individual app separately, but that functionality has been taken out since Apple tightened up sandboxing requirements.  However you should keep an eye on the TinyBird site (http://www.tinybird.com/) because the developer had emailed me some time ago mentioning that he was going to split out the Fn key controlling into a separate app—he was looking for testers at that time.  (It's been a while, so he might have dropped the idea.  Drop him a line if you want.)  The Keyboard Pilot app, incidentally, is indispensable for anyone who uses multiple keyboard layouts.

Link to comment
  • 2 years later...

Didn't work anymore on OS X 10.11.2. Found this solution:

on alfred_script(q)

tell application "System Preferences"
    reveal anchor "keyboardTab" of pane "com.apple.preference.keyboard"
end tell
tell application "System Events" to tell process "System Preferences"
    click checkbox 1 of tab group 1 of window 1
end tell
quit application "System Preferences"

end alfred_script
Edited by Davide
Link to comment
  • 1 year later...

I slightly changed the script so it will work. The difference in it is that i removed the word 'all' in the script where it was searching for the string "Use F1, F2, etc. keys as standard function keys"
Now i will work with the latest macOS update

on alfred_script(q)
tell application "System Preferences"
	set current pane to pane "com.apple.preference.keyboard"
end tell


tell application "System Events"
	if UI elements enabled then
		tell tab group 1 of window "Keyboard" of process "System Preferences"
			click checkbox "Use F1, F2, etc. keys as standard function keys"
		end tell
	else
		tell application "System Preferences"
			set current pane ¬
				to pane "com.apple.preference.universalaccess"
			display dialog ¬
				"UI element scripting is not enabled. Check \"Enable access for assistive devices\""
		end tell
	end if
end tell

tell application "System Preferences"
	quit
end tell
end alfred_script

 

Link to comment
  • 4 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...