3

Is there any shortcut for toggling what funtion keys (F1, F2, F3,…) do? I sometimes want them to do the special operations (eg. brightness) and sometimes use them for toggling things in Pages (you can set shortcut for Style etc.).

I am looking for solution without pressing fn key for one kind of functions. I know I can do some scripting and make little AppleScript app for toggling it but that's the last solution.

I have non Touchbar MacBook Pro running macOS Sierra 10.12.6, if that helps.

6
  • By default they have double functionality. By default those keys do the brightness adjustment and all that stuff, but if you hold down the fn key, they act like Function keys. So let's say you use an app that has a shortcut Alt + F4, to use it you'd actually press Fn + Alt + F4. Or am I misunderstanding your point?
    – Joonas
    Jan 18, 2018 at 23:28
  • @Joonas "I am looking for solution without pressing fn key for one kind of functions." Jan 19, 2018 at 17:30
  • Well yea, but you also say you don't want to use a script to toggle the state on and off. You are looking for a shortcut to toggle the functionality of those keys, but you seem to reject the only two possible ways to toggle that functionality using a shortcut. What else could you possibly do? A long press?
    – Joonas
    Jan 19, 2018 at 18:42
  • ...Or does @wch1zpink's answer do it exactly the way you want, except for what ever reason you don't want to use a script? I say take the solution and run. Nothing wrong about using scripts.
    – Joonas
    Jan 19, 2018 at 18:49
  • Well, I tried @wch1zpink's solution and it worked. I thought I can only run AppleScript using Script Editor or exporting it as app. Creating a service and than starting that service using shortcut looks like the way to go. I need it for toggling Styles in Pages and the only shortcuts you can use are F keys. And when you want to change style after every enter it is not very enjoyable pressing fn and the F key, when you have just one hand to do it (like holding mouse with the other one...). And also I am using Brightness and Volume buttons very often. Jan 19, 2018 at 20:43

3 Answers 3

6

This works for me using the latest version of Sierra and 15 inch MBP (non-touch bar)

Using Automator, create a new file and choose “New Service” as your option

Add A “Run AppleScript command” to your workflow, and insert the following AppleScript code

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

enter image description here

Save your new Automator service, naming it something like... "Toggle Function Keys"

Next, just open System Preferences/Keyboard/Shortcuts/Services And you should see your new "Toggle Function Keys" service Located in the "General" sub-menu And assign it a Keyboard shortcut.

enter image description here

Your new service can now be activated using the keyboard shortcut you created and in the "Services" menu while using any application.

enter image description here


You also have another option.

You own a Mac! It's a very powerful tool which is supposed to make your life easier. So make your life easier and let your Mac do your work for you.

If you are crazy lazy like I am, you can save that AppleScript code in my answer, in the script editor app as a script and name it something like “Toggle Function Keys.scpt”. You can make the action of toggling your function keys on and off “speakable”. Meaning you can run the script with a dictation command.

Here’s the process...

Enable enhanced dictation and dictation commands in your system preferences.

enter image description here

As you can see in my next image, I set “computer” as my keyword phrase...

enter image description here

Now with enhanced dictation ready to rock'n roll, I selected the “Toggle Function Keys.scpt” file in Finder and spoke the phrase “computer make this speakable”

Speaking that command opened up this dialog box

enter image description here

Now any time I want to toggle my function keys, I simply say the command “Computer Toggle Function Keys” and it runs “Toggle Function Keys.scpt” and performs all the actions in that script file

1
  • This is the best answer, but some of the UI has changed a little in Automator. When you create a new document, you need to select "Quick Action". Then the script just shows up in your services menu. I did not test accessing it the other ways.
    – Ron Davis
    Jun 4, 2020 at 16:03
1

I recommend BetterTouchTool, a little menu bar app that I have relied on for years. With it, you could either create universal shortcuts with or without modifier keys, or create application-specific shortcuts so the functions are determined by whichever application is frontmost. Because the F-keys are special, if you encounter controversial behavior, check System Preferences > Keyboard > Shortcuts and disable the shortcuts that hinder your own mappings. I haven't overwritten my F-keys so I can't remember if remapping them with BetterTouchTool causes controversy or not, but if it does, see System Preferences. It's easier to keep track of what functions dominate if you can aim to keep all the rules in one place.

2
  • I have and use BTT. I am hoping I can use BTT to set a gesture (e.g. 5 finger tap) to toggle the setting. Hopefully this can be done but it may require figuring out how to make BTT assign that gesture to the aforementioned applescript or other suitable automation. The standard suggestion of yours is insufficient because sometimes (e.g. in the terminal, or certain apps) I need F1 and F2, and the rest of the time it's good to have them control the brightness without hitting Fn. Anyway, the volume buttons are the bigger deal, since they are physically too far from Fn.
    – Steven Lu
    Jan 30 at 5:30
  • @StevenLu BTT allows you to define shortcuts either globally or for a specific application. A specific application's mappings will override the global BTT mapping, making an exception. It also has a concept called presets, which allows you to have several "profiles" if you wish to change the set of mappings even for one and the same application, context or whatever. I've never needed presets, as the application specific mappings give plenty of freedom already. You don't need to use fn either, you could map those keys to use any combo you prefer.
    – user158589
    Feb 12 at 21:22
0

Use case:

Sometimes, we are working or gaming and our app may have useful functionality bound to F-keys. So we want our "Use F1, F2, etc. keys as standard function keys" setting ON.

Other times when we are consuming content, we would like the setting OFF in order to easily adjust brightness and volume of the computer. In particular volume is troublesome when the option is ON because even though I can reach across 10 white keys on a piano, my hand is still too small to reach a chord of Fn+F11 or Fn+F12 to adjust volume.

This is how I set it up since F11 and F12 are not used in most apps:

  1. With BTT assign F11 and F12 to volume down/up respectively.
  2. Leave "Use F1, F2, etc. keys as standard function keys" setting ON.

Extra brownie points:

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .