Jump to content
MikeAlt

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

 

 

Share this post


Link to post

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

Share this post


Link to post

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.

Share this post


Link to post

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

Share this post


Link to post

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

 

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...