How to bring brightness controls back to your M1 Mac’s keyboard

Apple’s new laptops have a revamped keyboard layout with more dedicated function keys, but some previous options didn’t make the cut.

Some of the new offerings I find very useful, like the dedicated Spotlight key, which allows users to invoke Spotlight for program launches and file opening without moving the cursor up to the menu bar. Others, like the dedicated Do Not Disturb/Focus key and the Siri key, are of less use to me.

I use neither function, and immediately noticed they have replaced a pair of keys which I used to use frequently: the keyboard brightness keys. However, the good news is there is a way to bring them back.

This method involves creating a custom LaunchAgent, a small script which runs automatically on each login or reboot, and which tells the system to implement our custom keyboard shortcuts when pressing certain function keys. In this case, we will be telling the system to view presses of the F5 and F6 keys (currently Focus and Siri) as commands to lower and raise the keyboard brightness instead.

How to bring back keyboard backlight hotkeys

1) Open up TextEdit on your machine and create a new document.

2) If your machine is not already configured to create new documents as plain text (it likely isn’t), go to Format in the menu bar and select Make Plain Text to remove rich formatting from the current document.

3) Paste the following script into your TextEdit document:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.local.KeyRemapping</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/bin/hidutil</string>
        <string>property</string>
        <string>--set</string>
        <string>{"UserKeyMapping":[
            {
              "HIDKeyboardModifierMappingSrc": 0xC000000CF,
              "HIDKeyboardModifierMappingDst": 0xFF00000009
            },
            {
              "HIDKeyboardModifierMappingSrc": 0x10000009B,
              "HIDKeyboardModifierMappingDst": 0xFF00000008
            }
        ]}</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>

The resulting document should look something like this:

Ensure that the <?xml version=…> tag at the start of the document has been preserved when copying and pasting, and that the closing of the final </dict> and </plist> tags is also present. You can see that the above example is in plain text by the monotype font, lack of auto-capitalisation, lack of font style/colour, and lack of auto-spell-correction. The plain text prevents TextEdit from re-formatting the code, or from auto-correcting it and thus breaking it.

4) Now Save… your document to your Desktop, with the following name and file format:

com.local.keyRemapping.plist

Note: The resulting document has a file type of .plist. It should NOT be a .txt document. MacOS sometimes ignores the user’s wishes and automatically adds .txt to the filenames of documents saved by TextEdit. If your saved file is named com.local.keyRemapping.txt, or even com.local.keyRemapping.plist.txt, select it on the Desktop and manually rename it, deleting .txt and ensuring it ends only with .plist.

5) We now have our key remapping script. Copy it, and paste it into the following folder:

~/Library/LaunchAgents

This is the /User/Library folder, not the /Library folder at the root of the drive. It is located inside your own user folder, at /Macintosh HD/Users/YOUR_ACCOUNT_NAME/Library/LaunchAgents.

If you do not know how to find or open the ~/Library folder, see our more in-depth explanation on the topic.

6) Once your key remapping .plist is inside your ~/Library/LaunchAgents folder, reboot your Mac. This should cause the LaunchAgent to be detected and run for the first time, and enable its functionality.

You can now try pressing your F5 and F6 keys; they should now turn your keyboard backlight up and down. Please note, if you had previously set up custom keyboard shortcuts involving those keys in System Preferences, Keyboard, Shortcuts, they could be interfering with the script and should be removed. Any other problems are likely to be due to the correct formatting, naming, or placement of the script in ~/Library/LaunchAgents.

It goes without saying, but this will only work on laptops with the new keyboard layout which features F5 and F6 as dedicated Focus and Siri keys, and only on machines which have keyboard backlighting.

If you wish to revert your changes, simply navigate to ~/Library/LaunchAgents, and delete the com.local.keyRemapping.plist file that you find there. Then reboot your machine.

To use this script while also retaining somewhat quick access to Do Not Disturb/Focus and Siri, you can access Focus from the Control Centre in the top-right of your screen. Its logo is two toggles on top of each other. Siri can be added to the menu bar by going to System Preferences, Siri, Show Siri in menu bar.

In theory, this script could be edited to change various function keys’ functionality, though you would need to know the hex codes used by the script to refer to the various key mappings. If you know any more of these, where to find a comprehensive list of them, or have similar examples of key remapping scripts you have created, I’d love to see them!

Share any similar remappings, as well as any comments or questions, below.