Keychron Function Keys on Linux
Those who know me know that I am sort of a keyboard driven type of guy and prefer not to use the mouse if I don’t have to. This way, I don’t have to keep moving my hands around to navigate my workstation. That’s why System76’s Pop Shell tiling window extension for Gnome is installed in all my workstations running the Gnome DE regardless of distro unless I am of course, using Awesome WM instead.
I was also previously a Mac user for over 10 years which made the super key being closer to the space bar feel much more natural to me so when I bought a low profile 104-key Keychron mechanical keyboard 2 years ago after an extensive search for the perfect keyboard, I of course always used it in Mac mode.
This is where the problem first started for me. The Mac mode makes the multi-media keys default and to use the actual function keys (F1-F12), I have to press and hold the fn button and then press the function key that I wanted. As you can already guess, function keys are much more used than the multimedia keys for a tech guy so it was quite an annoyance. Just imagine trying to press ctrl-alt-fn-F3 just to switch to a diff TTY…. :/ FML…
After looking through the user manual and searching around online, the conclusion I derived was that it’s a behavior handled by the micro-controller on the keyboard that’s not changeable unless I used the Windows/Android mode which has a shortcut (fn-x-l for 4 seconds) to change this behavior.
Needless to say, that annoyed me quite a bit to have an imperfect perfect keyboard. So I decided to broaden my search and started lurking around on what is and isn’t exposed to the OS for Apple keyboards in general. Low and behold, I was able to find the below solution.
As root (sudo does not work):
echo 2 > /sys/module/hid_apple/parameters/fnmode
To make this configuration permanent so that it survives reboots:
echo "options hid_apple fnmode=2" > /etc/modprobe.d/hid_apple.conf
and that’s it. From that point on, F1–F12 is default and in order to use them as multimedia keys, you have to press and hold the fn key.