3

Can anyone please tell me how to read the current state of the Fn-key in Linux? Is the current state of my keyboard in "Fn" mode or "normal" mode? I know that I can find out by pressing the keys, but I rather know before I try out.

I just can't find any device or /proc or mapping or whatever, where I can find out if pressing Fn-F1 produces a "sound off" (configured in my case) or triggers the F1-action bound on the F1 key.

phuclv
  • 26,555
  • 15
  • 113
  • 235
CFrei
  • 83
  • 1
  • 6

2 Answers2

1

You generally can't. The Fn key works entirely in hardware, unlike modifier keys like Ctrl or Shift. You can find more information on the Fn Key wikipedia.

phuclv
  • 26,555
  • 15
  • 113
  • 235
Silbee
  • 965
  • 5
  • 11
  • Do you know if that is documented somewhere? – CFrei Apr 23 '21 at 12:39
  • Mostly but not entirely true - depends on the computer model. – harrymc Apr 23 '21 at 12:41
  • ...where can I find more documentation on this? – CFrei Apr 28 '21 at 03:36
  • 1
    You can find more information on the Fn Key wikipedia (https://en.wikipedia.org/wiki/Fn_key). This page also contains a number of references to other websites. And yes, harrymc is correct there are exceptions, most notably Mac computers (they CAN remap fn) and some pc models use ACPI calls for the Fn key. However, for the vast majority of the time, no remapping of the Fn key is possible. – Silbee Apr 29 '21 at 07:09
  • Please put this in the answer. That was what I was looking for. (Wiki did not cross my mind.) Thanks. – CFrei May 02 '21 at 11:29
1

It's not possible to do that on most common hardware, because the Fn key is completely unknown to the outside world except the keyboard controller and doesn't generate any scan code when pressing. Only when you hold it down in conjunction with another key then the keyboard controller will send the final scan code to the OS

There are some platforms where you can capture the Fn key status such as macOS or some custom boards. Everything is different on a Mac, even the Power button generates a scan code on it. If you aren't on such platforms, you're out of luck

But if you just want to get the function keys without pressing Fn then simply go into BIOS setup and change the setting to invert Fn behavior, most have that option along with the config to swap Fn/Ctrl keys. If there's no such option then you need to update the BIOS. You can also use the Fn-lock key on your keyboard if it's available

If there's a secondary option on F1 then you can also remap that combo to your desired action, for example if Fn+F1 produces the Volume down key then remap Volume down to the "sound off" action you want

phuclv
  • 26,555
  • 15
  • 113
  • 235