Optimize for happiness

Life is easier with simple scripting. Grateful for everyone's encouragement and support!

View this project on GitHub

Show desktop with one key?

2023.06.10   •   4 min read

I am back to using a mouse instead of a trackpad that had a convenient swipe gesture to show desktop. It’s something I miss, so: enter Karabiner Elements. A new modification was needed as I couldn’t find anything existing exactly how I wanted it. So I learned how to create one.

Default Mac shortcut: fn - F11 (on my Magic Keyboard with function keys not set as standard)

The convenience of the function key row is to use it for special functions, that come printed on those keys. For example, F3 will open Mission control which is a fancy name for arranging all open windows without overlap to be able to peek into them all at once. Those keys can also behave as standard ordinary function keys (F1, F2 and so on) in combination with fn (or the newer globe symbol key) - whatever you see on the bottom left of your keyboard. Check out your System PreferencesKeyboardKeyboard Shortcuts...Modifier Keys. You could really prank someone by changing any of them.


There are a lot of ways to modify the keys inside the Keyboard Shortcuts. For example, you can see that Mission control (all windows arranged to be visible) is also control - in addition to the F3 example above.

Unfortunately, under Keyboard ShortcutsMission ControlShow Desktop it’s assigned to F11 which to me is a little random and I find myself forgetting it given all the other things to try to keep track of. Also, it’s a standard function key so to get to it takes two keys fn - F11.

I wanted something more simple.

F3 already shows all windows, so it was logical to hit the next key F4 to temporarily hide all windows to get a look at the Desktop if I need to see if the download finished or to quickly open that one file that I know is there. As with all others, hitting F4 again undoes it and brings all the windows back. They didn’t go anywhere.

Note: F4 by default may be assigned as the search key (Spotlight) but I personally never reach for it to search when that works with command - spacebar.

Lo and behold, I ended up looking at Karabiner Elements again. Created F4-Desktop.json on GitHub that now lives under the Karabiner Complex modifications in the OS Functionality section, or just by using search in the import window. You can import it and use it from there, like we covered previously

Since the decision to use F4 is a very personal choice, let’s walk through how you can take complete control and assign any other function key.

  1. Karabiner will follow what you tell it through a .json file so let’s first download it from GitHub to start playing with it.

  2. Open it with TextEdit (or vi in command line) or any other text editor.

  3. See the line 10? "key_code": "f4"? That’s where I told Karabiner I’ll press F4 for this command. Change the 4 to another number and you get another F key. (Or modify the "from" section further by adding modifiers, if you like, that’s explained in the Karabiner documentation and would be a whole other topic).

  4. Save the F4-desktop.json and change the name so you are clear on what the new file does.

  5. In Terminal, you need to place your new .json file in ~/.config/karabiner/assets/complex_modifications.

  6. Open Karabiner-Elements application.

  7. Click on Complex ModificationsAdd rule and you will see the description of the rule you created. Karabiner automatically looks for any rules in the directory above and as long as they are formatted correctly, they will show up. If you are not seeing it, restart Karabiner, if still not there, then there is a mistake in the file. Take a look at it closely for all brackets, commas, any other punctuation mistake.

  8. Enable your rule and it’s on your list to use.

If you change your mind, remove the old rule, modify the .json file and add the rule again like we just did. This is an example of a local user created rule. No need to go online or import anything - you are in complete control.

Say Hi!