Life is easier with simple scripting. Grateful for everyone's encouragement and support!
View this project on GitHub
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 Preferences
→ Keyboard
→ Keyboard 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 Shortcuts
→ Mission Control
→ Show 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 withcommand
-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.
Karabiner will follow what you tell it through a .json
file so let’s first download it from GitHub to start playing with it.
Open it with TextEdit (or vi
in command line) or any other text editor.
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).
Save the F4-desktop.json
and change the name so you are clear on what the new file does.
In Terminal, you need to place your new .json
file in ~/.config/karabiner/assets/complex_modifications
.
Open Karabiner-Elements application.
Click on Complex Modifications
→ Add 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.
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.