Create a shortcut for changing Fn key behavior


I would like to create a shortcut that toggles the behavior of the function keys between standard function and "special features". Basically it would toggle this setting that is in the macOS system keyboard settings:

How would I do this? Thanks for the help.


defaults write -g -boolean false

This command doesn't seem to properly take affect. (Although I do see the value change when I read it back).

I don't know how to toggle that programatically.

One thing you could do, is to create a separate preset in BTT, where you record all the F keys and assign media functions to it. Then you activate that preset in BTT using the predefined action "switch to preset".
If that preset is active, BTT would then override the F keys with whatever functions you have assigned. If the preset is inactive you'd have standard F keys.

Ok so I found a solution that seems to be working.

The key is this command:

/System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -u

This reloads the settings after they been written via defaults write.

I added these 2 commands to a shortcut and now I have the functionality I want.


Nice find!

1 Like

I had trouble getting the previous suggestions to work in Ventura, but here's Apple Script for use in BTT action "Run Apple Script (async in background)" which also solves the original question for a shortcut that toggles the behaviour.

do shell script "if [[ $(defaults read -g '') == '0' ]]; then defaults write -g '' -boolean true; else defaults write -g '' -boolean false; fi; /System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -u;"