Kernel 5.14 bug: keyboard alt/windows keys swapped on bluetooth connection only

I’m fairly sure this is a kernel 5.14 bug and I need some help hunting it down and reporting it since I have not done that before. And it is a weird one!

I have a keyboard that connects over bluetooth and USB.

  1. When running kernel 5.14 and connecting the keyboard over bluetooth, the Alt and Windows keys are swapped. Alt opens the menu and Windows key acts as Alt. Also, I cannot type the € sign anymore using the right-alt + 5 key combination.
  2. It kinda looks like it is treated as an Apple keyboard, but the media functions are still tied to the Fn + function keys as is usual for a Windows keyboard.
  3. When running kernel 5.14 and connecting the keyboard over USB, the Windows and Alt key behave normally, i.e. Windows key opens the menu, Alt is Alt and I can type the € sign without issue.
  4. When running kernel 5.10 or 5.13 and connecting the keyboard over bluetooth, the Windows and Alt key behave normally, i.e. Windows key opens the menu, Alt is Alt and I can type the € sign without issue.
  5. When running kernel 5.14 ANOTHER bluetooth keyboard has no issues and the Windows/Alt keys work as expected with this other keyboard.

So, the problem only occurs with kernel 5.14 in combination with this specific keyboard connected over Bluetooth.

To me it looks like some weird HID misconfiguration issue and somewhere in the back of my mind I seem to recall a bit of uproar about a similar change a while back that was then reverted… but I can’t find any information on that anymore.

Is there anyone who feels like helping me hunt this one down and report it upstream? Thanks!

Technical details
The keyboard is a Royal Kludge G87 mechanical keyboard with Bluetooth and USB connectivity. I don't see it listed in lsusb output when connected over USB, it shows as "RK-Bluetooth keyboard" when connected over Bluetooth.

$ inxi -Fzxc0
System:    Kernel: 5.14.0-0-MANJARO x86_64 bits: 64 compiler: gcc v: 11.1.0 Desktop: Cinnamon 5.0.5 
           Distro: Manjaro Linux base: Arch Linux 
Machine:   Type: Laptop System: Dell product: XPS 13 7390 v: N/A serial: <filter> 
           Mobo: Dell model: 0G2D0W v: A00 serial: <filter> UEFI: Dell v: 1.10.0 date: 07/23/2021 
Battery:   ID-1: BAT0 charge: 49.3 Wh (100.0%) condition: 49.3/52.0 Wh (94.8%) volts: 8.7 min: 7.6 
           model: SMP DELL G8VCF6C status: Full 
           Device-1: hid-98:fd:b4:7a:93:66-battery model: ThinkPad Bluetooth Laser Mouse charge: N/A 
           status: Discharging 
           Device-2: hid-dc:2c:26:d2:c0:2f-battery model: RK-Bluetooth keyboard charge: N/A status: Full 
CPU:       Info: Quad Core model: Intel Core i7-10510U bits: 64 type: MT MCP arch: Kaby Lake note: check rev: C 
           cache: L2: 8 MiB 
           flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx bogomips: 36812 
           Speed: 800 MHz min/max: 400/4900 MHz Core speeds (MHz): 1: 800 2: 800 3: 800 4: 765 5: 708 6: 800 7: 800 
           8: 792 
Graphics:  Device-1: Intel CometLake-U GT2 [UHD Graphics] vendor: Dell driver: i915 v: kernel bus-ID: 00:02.0 
           Device-2: Microdia Integrated_Webcam_HD type: USB driver: uvcvideo bus-ID: 1-5:2 
           Device-3: Logitech HD Pro Webcam C920 type: USB driver: snd-usb-audio,uvcvideo bus-ID: 5-2.3.3:6 
           Display: x11 server: X.Org 1.20.13 driver: loaded: modesetting resolution: 1: 1920x1080~60Hz 
           2: 3840x2160~60Hz 
           OpenGL: renderer: Mesa Intel UHD Graphics (CML GT2) v: 4.6 Mesa 21.2.1 direct render: Yes 
Audio:     Device-1: Intel Comet Lake PCH-LP cAVS vendor: Dell driver: snd_hda_intel v: kernel bus-ID: 00:1f.3 
           Device-2: Logitech HD Pro Webcam C920 type: USB driver: snd-usb-audio,uvcvideo bus-ID: 5-2.3.3:6 
           Device-3: Realtek USB Audio type: USB driver: snd-usb-audio bus-ID: 5-2.3.4:7 
           Sound Server-1: ALSA v: k5.14.0-0-MANJARO running: yes 
           Sound Server-2: JACK v: 1.9.19 running: no 
           Sound Server-3: PulseAudio v: 15.0 running: yes 
           Sound Server-4: PipeWire v: 0.3.34 running: no 
Network:   Device-1: Intel Wi-Fi 6 AX200 vendor: Rivet Networks driver: iwlwifi v: kernel port: efa0 bus-ID: 02:00.0 
           IF: wlp2s0 state: up mac: <filter> 
           Device-2: Realtek RTL8153 Gigabit Ethernet Adapter type: USB driver: r8152 bus-ID: 6-2.4:4 
           IF: enp62s0u2u4 state: up speed: 1000 Mbps duplex: full mac: <filter> 
Bluetooth: Device-1: Intel AX200 Bluetooth type: USB driver: btusb v: 0.8 bus-ID: 1-7:3 
           Report: bt-adapter ID: hci0 rfk-id: 1 state: up address: <filter> 
Drives:    Local Storage: total: 476.94 GiB used: 355.92 GiB (74.6%) 
           ID-1: /dev/nvme0n1 vendor: SK Hynix model: PC601 NVMe 512GB size: 476.94 GiB temp: 44.9 C 
Partition: ID-1: / size: 467.01 GiB used: 355.7 GiB (76.2%) fs: ext4 dev: /dev/dm-0 mapped: cryptroot 
           ID-2: /boot size: 968.3 MiB used: 185.2 MiB (19.1%) fs: ext4 dev: /dev/nvme0n1p2 
           ID-3: /boot/efi size: 499 MiB used: 36.7 MiB (7.4%) fs: vfat dev: /dev/nvme0n1p1 
Swap:      ID-1: swap-1 type: file size: 16 GiB used: 0 KiB (0.0%) file: /swapfile 
Sensors:   System Temperatures: cpu: 42.0 C mobo: N/A 
           Fan Speeds (RPM): cpu: 0 fan-2: 0 
Info:      Processes: 267 Uptime: 20m Memory: 15.33 GiB used: 2.63 GiB (17.1%) Init: systemd Compilers: gcc: 11.1.0 
           clang: 12.0.1 Packages: 1683 Shell: Bash v: 5.1.8 inxi: 3.3.06


So I had the exact same issue today but with my Logitech MX Keys keyboard connecting via Bluetooth. To keep a long story short, I had to press Fn + P to set the keyboard into Windows mode. There is also a Mac mode on that keyboard using Fn + O.

After settling the keyboard to windows mode I had to reboot and it all worked again.

Perhaps your keyboard has something like this setting?

1 Like

My keyboard doesn´t appear to be able to switch between Apple/Windows layout. I have tried all possible key combinations I found on the internet for keyboards from the same manufacturer, but none worked. There is no information at all about this keyboard being able to switch.

But also, on kernel 5.10 and 5.13 the keyboard works fine in default Windows mode. It is only kernel 5.14 that switches keys around.

Looping in because I’m also similarly affected. As of now, I return to 5.10 where the issue doesn’t exist. I’m about to create issue at upstream’s bugtracker since my search doesn’t reveal any existing report. I’m currently working so I haven’t gotten the time to gather technical details. Please write it first if you already have one, I’ll add mine later.

For the record, my problem is that all function keys behave as multimedia keys, same as if it’s connected over USB instead of Bluetooth. There’s no Fn lock in this keyboard (Keycool KC84) and in kernel 5.10 Fn+function key switches the function keys to multimedia keys, however in 5.14, Fn+function keys behave the same as function keys alone, it’s all multimedia keys only. Switching between Apple/Windows layout doesn’t change the behavior, so it must be something else.

I’m at work too, but I’ll see what I can do today. I’ll report back here :slight_smile:

Good to know I am not the only one experiencing issues. It looks like some mix-up of half-n-half recognizing keyboards as Apple and Windows. For me the Function keys work like Windows keys but the Windows/Alt keys are inverted, for you it’s the Function keys that get switched to Apple default media functions.

Alright, I have solved my problem, but in a rather crappy, hacky way. Here’s the story:

  • I have a Keychron K8 keyboard as my main keyboard
  • that keyboard either has a weird firmware or Linux is weird about how it treats this keyboard
  • I have messed around and found a working solution a while ago
Click for working solution for using the Keychron K8 keyboard on Linux in cabled mode

When using the keyboard with a cable connection, I switch the keyboard to Apple mode. The problem is that Linux then treats the keyboard as an Apple keyboard, so all the function keys work as media keys, OPT and CMD are switched, etc.

I want to use the keyboard like:

  • function keys are function keys
  • media keys are Fn + function keys
  • F5 + F6 must also be function keys
  • OPT and CMD keys must be Super and Alt.

In order to achieve this, you need to edit or create the file /etc/modprobe.d/hid_apple.conf and put the following in there:

options hid_apple fnmode=2
options hid_apple swap_opt_cmd=1

Reboot your computer for this to take effect.
Next, you will notice that F5 and F6 are still bound to the backlight function. On the keyboard press Fn + K + C for 3 seconds.

TLDR: I have my Keychron keyboard switched to Apple mode and

options hid_apple fnmode=2
options hid_apple swap_opt_cmd=1

in /etc/modprobe.d/hid_apple.conf

For use on the road, I have a cheap Royal Kludge G87 mechanical keyboard. It has Bluetooth and when paired, it would work out of the box. Everything hunky-dory.

Then the problem with the windows key and alt being swapped on my G87 keyboard as described above popped-up.

After copious tinkering, the solution I have come up with is:

  • switch Keychron K8 keyboard to Windows mode
  • remove options hid_apple swap_opt_cmd=1 from /etc/modprobe.d/hid_apple.conf
  • sudo mkinitcpio -P
  • reboot

Now both my Keychron K8 and the Royal Kludge G87 both work as intended.

My frustrations:

  • I don’t understand what is happening here
  • the G87 keyboard used to be recognized as a bog standard Windows keyboard, but suddenly ONLY ONE of the options in the hid_apple.conf appears to get applied to it, so something was changed
  • the G87 keyboard gets recognized normally and functions as intended on another PC
  • when I switch the Keychron keyboard to Windows mode, hid_apple.conf still gets applied to the function keys but no longer to the Windows/alt keys
  • this should Just Work™

Interesting, my keyboard also loads hid_apple in 5.14. So I guess there’s a culprit trying to Apple-ize our beloved bluetooth keyboards. I think I’ll go back to 5.10 for now, it’s LTS anyway.

EDIT: confirmed fnmode=2 option for hid_apple works on my Keycool KC84. I’m going to create an upstream bug report for this. Feel free to add details there.

EDIT2: link to bug report:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.