How to swap the “fn” use of Function keys on a *generic* Keyboard in Linux

After searching the internet for some answers, the only things I was able to found are related to the Apple keyboard.

My question is the same as in this question How to swap the “fn” use of Function keys on al Apple Keyboard in Linux but is more generic: I'd like to know if is possible to do the same thing done in the linked question with a standard pc keyboard under linux.

I suppose that there is a method to swap the Fn behaviour ( not from the BIOS, as I don't have that option ), but wasn't able to find a guide or how-to to change this.

Thanks :)


Solution 1:

Fn is not a normal keyboard key, such as the modifiers Ctrl, Shift and AltGr. For a standard modifier key, the microcontroller inside the keyboard sends a scancode for the modifier itself, which is then interpreted by the operating system and combined with other simultaneous key-presses. The Fn key is a form of meta-modifier key, in that it causes the operating system to see altered scancodes when other keys on the keyboard are pressed. This allows the keyboard to directly emulate a full-sized keyboard, so the operating system can use standard keymaps designed for a full-sized keyboard. However, because the operating system has no notion of the Fn key, the key can not normally be remapped in software, unlike all other standard keyboard keys.

While it is most common for the Fn key processing to happen directly in the keyboard micro-controller, offering no knowledge to the main computer of whether the Fn key was pressed, at least one manufacturer, Lenovo, performs this mapping in BIOS running on the main CPU. This allows remapping the Fn key by modifying the BIOS interrupt handler.

Source: http://en.wikipedia.org/wiki/Fn_key#Technical_details

Answer to the question: Remapping not possible via operating system but only via BIOS (in some cases).

Solution 2:

I have this problem, and I found an answer not for generic keyboard but for a Lenovo Thinkpad so I think I should mention it here. It is mentioned in question 648250: hold down "Fn" and tap "Esc" - on the T440 / T440p at least, this acts as "Fn lock" and effectively reverses the Fn behaviour, as required.