DEV Community

Cover image for Keychron Linux Function Keys
Chris Texe
Chris Texe

Posted on

Keychron Linux Function Keys

I have a Keychron K8 keyboard. I like this keyboard so much! If you have a Keychron keyboard you noticed that in Linux when you press e.g. F2 key in order to change name of some file you adjust brightness (in my case). Default behavior of these keyboards is multimedia keys in function keys.

The second problem I noticed: reconnection takes very long time. I had to try many times to connect after disconnect. It was so frustrating...

So I found a solution in these two articles:

  1. Mike Shade
  2. Andre Brait

Mike resolved problem with function keys in Keychron keyboard.

  • 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. (usually all that's necessary on Windows)

  • type echo 0 | sudo tee /sys/module/hid_apple/parameters/fnmode in terminal

Andre resolved problem with slow reconnection via Bluetooth:

  • Edit the file /etc/bluetooth/main.conf
  • Uncomment FastConnectable config and set it to true: FastConnectable = true
  • Uncomment ReconnectAttempts=7 (set the value to whatever number that you want)
  • Uncomment ReconnectIntervals=1, 2, 3

What I did additionally was creating autostart above commands when my system is starting up.

  1. Create a file '/opt/my_scripts/keychron.sh'
   #!/bin/sh
   #sleep 20
   echo 0 | tee /sys/module/hid_apple/parameters/fnmode
   exit 0
Enter fullscreen mode Exit fullscreen mode

Notice there is no sudo in this file!!!

  1. Make this file executable by typing sudo chmod a+x /opt/my_scripts/keychron.sh

  2. Create a service file: sudo touch /etc/systemd/system/keychron.service

  3. Edit this file sudo xed /etc/systemd/system/keychron.service and paste it:

   [Unit]
   Description="Keychron service"

   [Service]
   ExecStart=/opt/my_scripts/keychron.sh
   Restart=on-failure
   RemainAfterExit=true

   [Install]
   WantedBy=multi-user.target
Enter fullscreen mode Exit fullscreen mode
  1. Start this service sudo systemctl start keychron

  2. Make it lauch automatically upon booting sudo systemctl enable keychron

That's it. From now when I boot my system my function keys are working not in "multimedia mode" and Bluetooth reconnection is very, very fast.

Top comments (0)