How do Fn keys work?
Solution 1:
Synetech gives a very readable explanation about the Fn keys here
Technical Details
When you press a key on a keyboard, the keyboard controller (a small IC chip inside the keyboard) detects the electrical circuit and processes it to decode which key was pressed and then sends the scancode to the motherboard. The operating system receives scancode from the BIOS and then performs whatever action it needs to in order to process that keypress.
With most keys, this is simple enough. If you press the A key, its keyboard controller sends the scancode to the motherboard which then passes it to the OS which in turn usually prints 'A'. (If the OS detects that one of the modifier keys is currently held down, then it may do something different. In fact, you can configure it to do whatever you want when the A key is pressed with or without modifiers.)
Now the Fn key is special. When you press it by itself, nothing happens because it is exclusively a modifier key and is not (generally) meant to do anything on its own. When you hold it and press another key, the keyboard controller detects that and looks in its built-in table to see if it is a known combination. If the combo is not in the table, then it just ignores it, but if the combo is in the table, then it looks up the associated scancode and sends that.
What does the OS end up seeing? It does not see the scancode for the Fn key and the scancode for the other key. Instead, it sees a single scancode associated with whatever function the Fn-combo has been set to. For example, if the laptop manufacturer has set the Fn+Down Arrow combo to reduce the volume, then the OS sees the scancode associated with the Volume Down, which some keyboards actually have.
Also note that the Fn key works independently from the operating system.
Moreover, this article may help point you in the right direction:
The kernel has its own
scancode
tokeycode
mapping table, so it maps a certain scancode to a keycode. You can look into /usr/include/linux/input.h to see what your kernel uses for scancode to keycode mapping – it is called akeymap
.
Postscript
I might need to somewhat renege on the earlier claim that the Fn keys work entirely independently of the OS; without going into more technical details here, the upshot seems to be that your OS might not "support" all or some of your keyboard's Fn keys, see, for instance:
- https://wiki.archlinux.org/index.php/extra_keyboard_keys
- https://unix.stackexchange.com/questions/274715/blue-fn-function-keys-not-working-with-lubuntu-on-my-thinkpad