The "Fn" key is local.

You've come to this page because you've asked a question similar to the following:

What is the scancode/HID "usage" for my Fn key? Why isn't it on the layout diagrams for my keyboard maps? Why can I not re-map it to another physical position?

This is the Frequently Given Answer to such questions.

The Fn key is entirely local. It does not appear on keyboard layouts because as far as the operating system is concerned, it does not exist. It is handled entirely by the microprocessor in the keyboard itself. Knowledge of it is not sent over the wire, between your keyboard and your computer. There's no USB HID "usage" denoting it. It has no scancode in the old PS/2, PC/AT, PC/XT keyboard device architecture.

The point of the Fn key is to reduce keyboard size by doubling up physical keys. A full "multimedia" keyboard nowadays has upwards of 124 keys, in 7 rows. The Fn key allows, amongst other things, doubling up the function keys on row K as multimedia keys from row L/M, and doubling up various keys in the main keypad as keys from the cursor and editing keypads. This is commonly employed on laptop and other size-constrained keyboards.

The keyboard microprocessor handles your Fn key as an entirely local modifier key. It uses the current Fn shift state to determine the usages/scancodes that are sent over the wire for other keys, including the keys that double-up as both function keys and (say) multimedia keys. This is why on some keyboards one needs to press (say) Fn+F4 to actually get function key 4 sent over the wire.

In fact, laptop and suchlike keyboards usually have two such local modifiers. The other is the state of the NumLock LED (sic), making every key have four different ways in which it can appear on the wire to your computer. In a number of modern keyboard microprocessors, there are thus four internal maps from physical keys to the HID "usages" or PS/2 scancodes that get sent over the wire.

On many such (but not all) keyboards the microprocessor also implements a Fn Lock. Like ⇫ Shift Lock does for ⇧ Shift, Fn Lock sets the sense of the Fn shift state. When the lock is on, the sense is inverted. On some keyboards, there is even a Fn Lock key chord, a doubled-up also local meaning for another key, such as Fn+⇬ Capitals Lock.

As seen by your computer, at the other end of the wire, all of this is invisible. Your computer sees a full keyboard with a real, independent F4 key. That is what X applications see in X input events, and what is seen at a low level in PS/2 keyboard device and USB HID drivers.

For some keyboards with Fn Lock, the manufacturer also provides a vendor-private USB HID output report mechanism for setting it from the host. This mechanism is what a machine firmware's SETUP utility invokes when it lets you switch Fn Lock, and what utilities like the Lenovo Keyboard "Driver" invoke on Windows. Outwith this, though, operating systems and applications have no knowledge of Fn.

Further reading


© Copyright 2020 Jonathan de Boyne Pollard. "Moral" rights asserted.
Permission is hereby granted to copy and to distribute this web page in its original, unmodified form as long as its last modification datestamp is preserved.