So I am trying to play my favorite MMORPG, FFXIV, on my M4 Mini. Having spent years playing it in winblowz I had like a dozen game actions bound to my f-keys. I shoulda realized that would cause an issue on the Mac side. I found a setting to turn off any Mac side use of f-keys, I hope that fixes the game issue. But what to do? Looking things over I see mostly 2 f-keys on the Mac side I use, quite frequently. Yeah, hold fn and hit the key. But I am wondering if anyone knows of a better way… like some way to automate the transition so I don’t have to manually keep switching it on and off everry time I play or quit the game.
I have good news and bad news.
The good news is that Karabiner Elements can do exactly what you want, for free. I use it for this very purpose.
The bad news is that to make it change the function keys for specific applications is a custom rule (what Karabiner calls a “complex modification”, and how to create these rules is non-trivial.
Update: I’d upload an example of a file that does function key changes, but Discord won’t let me. The only kind of file we can upload is PDF? The complex rules file is .JSON.
It seems like you want the top row of the keyboard to default to F-keys rather than the function indicated by the icon. You can do that through a System Setting. Specifically, System Setting>Keyboard>Keyboard Shortcuts (button)>Function keys (Sidebar)> ‘Use F1, F2, etc. as standard function keys’(toggle).
Toggling that will now execute the F function on a key. The ‘fn’ key will temporarily toggle the key to the icon function.
I actually tried it, but had zero clue what to do, so I uninstalled as I spent half an hour giving it all sorts of privileges for a whole bunch of unfamiliar stuff. I’'m still not 100% sure I’ll keep playing the game on my Mac… it’s kinda looking like some plug-ins that I “must” have are causing freezing issues.
It should be possible to create a Shortcut program to toggle the Fn key setting off and on - maybe in conjunction with an Applescript. I am currently reading Take Control of Shortcuts and will keep this purpose in mind.
I have an AppleScript for toggling the Fn keys – I used it before Karabiner – but I can’t get it to work on Sonoma. The problem is that the security refuses to allow the script’s GUI scripting to work, even though I have granted the signed app the necessary assistive access permission.
I’ll check out Shortcuts… all I am looking for it to toggle the System Pref on and off with one click, not play with the fn key.
Yeah, sorry, uploads are restricted to image files and PDFs for security reasons.
For future reference, here’s how to set up Karabiner-Elements to map Fn keys as Fn keys, as God intended, in specific applications. That is, when the particular application windows are in the foreground, the pressing F1 does F1 instead of adjusting the screen brightness or whatever. This is using Karabiner 15.3, which supports Ventura and later.
-
Download Karabiner-Elements
-
Install, following the prompts to grant it the necessary permissions. More instructions.
-
You need to find out how to identify your application. Select Launch EventViewer from the Karabiner menu applet, and then Frontmost Application in the sidebar.
-
Switch to the desire application, and then back to the EventViewer. Notice it displays the Bundle Identifier and File Path of that application. Save this, and you can close EventViewer.
-
Open this link to my example configuration file. Copy it to the clipboard (command a, command c) and save it to a .JSON file of your choosing. For example, my file is Function Keys.json.
-
You need to edit this file and set the application identifier for every key. This example is set to be active for two applications, using two different methods.
The first example is using a bundle_identifier, which is the preferred method. com.microsoft.rdc.macos is the bundle identifier of Microsoft Remote Desktop, which is now confusingly called Windows App.
The second example is for IBM Host on Demand, which is a Java app. You can’t use the bundle identifier in this case, because the bundle is Java; it would act on every Java app. So in this case it uses the app’s folder name.
Note that in both cases these are actually regular expressions, which is why the bundle identifier starts with ^ and ends with $. The file_path is matching the end of the application’s path. In both cases the periods must be escaped with a double \.
-
Now you need to get the rule imported into Karabiner. One way is to open the Karabiner Settings > Complex Modifications > Add your own rule, and then paste the contents of you JSON file there. Once it adds it, turn it on.
Another way is to save the .json file to ~/.config/karabiner/assets/complex_modifications, Karabiner should pick it up and then let you turn it on.
Ha, I see Shortcuts can get added to the dock so one doesn’t have to open the app to run them… I was hoping for something like a droplet, but w/e. Unfortunately there was nothing in there about changing the System Setting I wanted to toggle on and off.
I had the same problems when I “upgraded” to Sonoma. I had some Applescript that I wrote many years ago to do a screen area capture and paste the clipboard into GraphicConverter (Cmd-J). The Mac refused to allow keystrokes. In the end I found a built-in GC command to achieve the same outcome:
For best usage, load into Script Editor and Save As an Application with the Runtime box checked. Drag the application to the Dock for ready access.
Excute Unix command
do shell script “screencapture -i -c”
Ensure GraphicConverter is active (caution: no error trapping here)
tell application “GraphicConverter”
activate
The next line can be used instead of the keystroke routine new image from clipboard this is a built-in GC script
new image from clipboard
end tell
Here is my original Applescript (that worked in Mojave)
get ready to send keystrokes
tell application “System Events”
make GC the active application
tell process “GraphicConverter”
set frontmost to true
end tell
send the keystrokes
keystroke “j” using {command down}
end tell
BTW Maybe there is a shell script (Unix command) for your purposes?
I have a similar problem when I play Minecraft, on my old but worthy Mid 2012 MacBook Pro, running macOS 10.13. I’m using Fluor - “A handy tool for macOS allowing you to switch Fn keys’ mode based on active application”, and it works well for me (albeit in my aged environment).
Hmmm, I did find an old project on github from 9-10 years ago that said it would do what I want, BUT the was no way to download it. Seems based on AppleScript (haven’t they totally deprecated AppleScript?). They also recommend something called Homebrew Cask. I am aware of a Homebrew that I think adds some Unix level tasks invoked via the command line. Unfortunately, the link to this item shows a 404.
Can you give me any guidance on how to get this part done?
I’m not sure if you are replying to my post - I suspect not? But I would suggest taking a look at Fluor - I think it is aimed at solving the problem you described in your original post (“automate the transition [between Apple / ‘standard’ function key settings] so I don’t have to manually keep switching it on and off everry time I play or quit the game”), and if it works, no coding is required.
The screen shots on the main page I linked to seem broken, but if you look in the relevant folder, you can see them to get a better idea about what this app does.
Here’s the “rules editor”. You can set up a list of applications, and whether the keyboard should be in “default Apple function keys” or “good old function keys: F1, F2…” mode for each.
The Github page says this app is written mostly in Swift. I found it easy to install and use. It can be downloaded from the Releases page - download the .dmg
file from there. The latest version is from 2022, marked “for Apple Silicon”, so it might work with your M4.
Thanks for this! I’m not the OP, but I saw you mention Minecraft in a previous post, and I thought “me too!”
I can report that Flour works as intended in Minecraft on a MBP M1 Pro. Now…is that hopper enabled or not?
Yes Ashey, I was referring to your first post. I got the binary, but it seemed to say I needed to install something called “Homebrew Cask.” The link was broken. Then looking closer I think it meant Flour can be run. in Homebrew. So I just ran the app, it wanted me to OK notifications and have control over my machine. I gave it what it wants. THEN I launch it and nothing at all happens.
Then I remember Console, so I ran that. Hmmm, not the way I remember it from the HS and earlier days. Don’t see what I used to see, which was kind of a second by second log of what was going on. It DID have a crash tab, and the only thing there was some app that crashed several days ago. AND it didn’t say a peep about a few real freezes I have had recently.
BUT somehow running it changed my keyboard settings. I had to re-engage the option to use the fn key to “use the special features printed…” Above it it says Use F1… as standard function keys. Oh I guess they mean to NOT use what the fruit wants users to do with those keys. Anyway, after re-enabling that option things are back the way I want.
I pretty much solved my issue by setting screen corner to launch Launchpad and Mission Control. Thanks to everyone posting here!
Ooof I wasn’t expecting any of that. Sorry Paul. I just checked - I’m using an older version of Fluor (version 2.1.0), which I installed in 2020, and I didn’t have to deal with Homebrew, I think. Perhaps it changed to add some of that complexity later? Anyway, glad you have solved the issue.
My notes say another utility like Fluor is FunctionFlip. I don’t know if it works.
There used to be a Palua app in the Mac App Store, but it stopped working long ago.