Skip to content

Instantly share code, notes, and snippets.

@echosergio
Last active March 4, 2022 08:37
Show Gist options
  • Save echosergio/6babe08a06d3ce9ffc975fc9aa0e1aed to your computer and use it in GitHub Desktop.
Save echosergio/6babe08a06d3ce9ffc975fc9aa0e1aed to your computer and use it in GitHub Desktop.
KEYCHRON LINUX FUNCTION KEYS

On Linux, the Keychron K2 doesn’t register any of the F1-F12 function keys as actual F keys, instead, treating them as multimedia keys by default.

This section of the document describe how to change the behavior of 'fn' key to better match what user expect.

Here a description of each behavior :

  • 0 = disabled : Disable the 'fn' key. Pressing 'fn'+'F8' will behave like you only press 'F8'
  • 1 = fkeyslast : Function keys are used as last key. Pressing 'F8' key will act as a special key. Pressing 'fn'+'F8' will behave like a F8.
  • 2 = fkeysfirst : Function keys are used as first key. Pressing 'F8' key will behave like a F8. Pressing 'fn'+'F8' will act as special key (play/pause).

To fix this:

  • Set the keyboard to Windows mode via the side switch
  • Use Fn + X + L (hold for 4 seconds) to set the function key row to "Function" mode.
  • echo 2 | sudo tee /sys/module/hid_apple/parameters/fnmode
  • Optionally, reboot sudo reboot

Once complete, my F1-F12 keys work properly, and holding Fn turns them into multimedia keys. You can use the evtest utility to check how keyboard keys are registering until you get the above combination of settings configured properly.

To persist this change, add a module option for hid_apple:

echo "options hid_apple fnmode=2" | sudo tee -a /etc/modprobe.d/hid_apple.conf

You may need to rebuild your initramfs if hid_apple is included.

sudo update-initramfs -u -k all

To (re-)load the module for immediate use, run

sudo modprobe -r hid_apple; sudo modprobe hid_apple

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment