Create a shortcut for changing Fn key behavior

HI,

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.

Edit:

defaults write -g com.apple.keyboard.fnState -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.

1 Like

Nice find!

1 Like