Remap FN to another key

Can the Fn Key Be Remapped or Disabled?

Digging into remapping Fn combinations via a program like AutoHotKey, or digging into keyboard scancodes for Windows, one may be able to remap the offensive key combinations (Fn + Key). (see further down this answer).

As the Fn key is usually at the hardware level, it would not be able to edit or disable this doing so at this level.

[Fn] This is typically a hardware key that does not generate a separate code.

Source: UI Events KeyboardEvent Code Values - W3C Candidate Recommendation, 2017


On a Similar Key, the F-Lock, Jason Tsang, Microsoft MVP, Says the Following:

The F Lock key is a hardware switch in the keyboard. Its state cannot be controlled programmatically. Its default condition is "off". As a result, whenever the keyboard is reset, or loses power, the F Lock key will always be in an "off" state. Do note that with the Microsoft keyboards released after September 2004, the keyboard will retain F Lock status through a reboot.

Source: Microsoft Keyboards - F Lock Key


What is the Fn Key? Some more detail:

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.

Sources - A) highrez forum post likely based on B) wikipedia post


Why is it Often Seemingly Impossible to Map the Fn Key?

Indeed, keyboard work as follow (values are just examples, behavior is simplified):

  • Normal keys: send byte 0x00 + key scan code byte
  • Modifiers (alt/option, control, windows/command and fn): sends modifier scancode byte + key scan code byte
  • Special keys (like the G15 ones): send standard (like the volume keys) or custom (depend on manufacturer) scancodes

Most "fn" keyboards (apple included) just process the key combination before sending data, so pressing and releasing the fn key will do nothing at all. For example:

  • Pressing F1 -> Scancode 0x1A -> operating system recognizes as F1 key
  • Pressing FN and F1 -> Scancode 0x9A -> operating system recognizes as VolumeUp key
  • Pressing FN -> keyboard microcontroller waits for another key before sending any data

Source: AutoHotKey Forum


One Poster on AutoHotKey Starts With a Rhetorical Questions

I don't get any response when I press the Fn key.

The fn key is not supposed to send any signals. What it does is change the signal that is sent when you press another key...

So the real deal about Fn-key is that it simply doesn't exist to the OS, so you cannot actually "remap" it in the OS. All you can do is remap the secondary function of some key by remaping a key to send the fn-modified single signal...

So basically, automating fn-key is not feasible. However automating its final result is no problem! ...

So unfortunately no automation will be feasible on the OS level: you would have to go down to hardware/driver level and that is not feasible through AutoHotKey.

Source: AutoHotKeyForum Post


Some People Have Had Success Remapping Fn Functions via Autohotkey, and a Few Have Even Had Success Seeing the Fn Key.

...you might still be able to make it a hotkey by using the following steps:

  • Ensure that at least one script is running that is using the keyboard hook. You can tell if a script has the keyboard hook by opening its main window and selecting "View->Key history" from the menu bar.
  • Double-click that script's tray icon to open its main window.
  • Press one of the "mystery keys" on your keyboard.
  • Select the menu item "View->Key history" Scroll down to the bottom of the page.
  • Somewhere near the bottom are the key-down and key-up events for your key.
  • NOTE: Some keys do not generate events and thus will not be visible here. If this is the case, you cannot directly make that particular
    key a hotkey because your keyboard driver or hardware handles it at a level too low for AutoHotkey to access. For possible solutions, see
    further below. If your key is detectable, make a note of the 3-digit
    hexadecimal value in the second column of the list (e.g. 159). To
    define this key as a hotkey, follow this example:
SC159:: ; Replace 159 with your key's value.
MsgBox, %A_ThisHotkey% was pressed.
return

Reverse direction: To remap some other key to become a "mystery key", follow this example:

; Replace 159 with the value discovered above. Replace FF (if needed) with the
; key's virtual key, which can be discovered in the first column of the Key History screen.
#c::Send {vkFFsc159} ; See Send {vkXXscYYY} for more details.

Source: autohotkey.com/docs/KeyList.htm


Using AutoHotKey for Remapping Via DLL

AutoHotkey is an open source macro-making utility for Windows, and one of its many features is creating hotkeys. Micha, one of the members of the AHK forums, created a DLL file to add support to AHK for Human Interface Devices. Using this DLL file, it's possible to readout keys of practically every HID; keyboards, mice, remote controls, etc.

Here Is What the DLL Process Creator Says in an Old Article:

First of all, some information on the workings of the keyboard and the Fn key in particular. Each key has its own unique code, a scan code, by which the computer it's connected to can find out if a certain key is pressed and when it's released. The Fn key works a bit different. When you press and hold the Fn key, it'll change the scan codes of (some of) the other keys on the keyboard, so that a single key can send different scan codes back to the computer, each connected to a different function. That's why the Fn key is often used on notebooks, smaller keyboards or keyboards with a lot of multimedia keys. That way you can add many functions to a relatively small amount of keys.

The problem is that the Fn key usually doesn't have its own scan code. Depending on the keyboard and the computer it's connect to, it's possible that the Fn key doesn't modify the scan codes of the other keys, and therefor doesn't work. Because it also doesn't send out a scan code of its own, there's no way for the computer to know that there even is an Fn key, let alone what to do when it's pressed in combination with another key. Remapping tools can't help you either, because they're also based on the use of scan codes.

Example of Recording Fn Key Value Based on Instructions:

Once it's running, press your Fn key, or another special key, and write down the corresponding value.

; Filter bit 5 (Fn key) Transform, FnValue, BitAnd, 16, KeyStatus

Sample Code For Remapping Fn Function

;
; Fn + Backspace = Delete
;
$Backspace::hotkeyBS()

hotkeyBS() {
global fnPressed
if (fnPressed = 1) {
Send {Delete}
} else {
Send {Backspace}
}
}
Return

Source: Follow Full Instructions Here

  • Download Most Recent AutoHotKey Here
  • Github Unofficial Apple Wireless Keyboard Support (UAWKS)
  • Download Github UAWKS Most Recent FnMapper.ahk File Here
  • Download Github UAWKS Most Recent AutohotkeyRemoteControl.dll File Here

**SharpKeys**

Download Here; there is an article here.

SharpKeys is a utility that manages a Registry key that allows Windows to remap one key to any other key. Included in the application is a list of common keyboard keys and a Type Key feature to automatically recognize most keyboard keys. It was originally developed in C# using .NET v2 but has been updated to support .NET 4.0 Client Profile.

Also KeyTweak

KeyTweak is a simple utility that allows users to redefine their keyboard input signals. The functionality is made possible by a registry value first documented in Windows 2000, but also present in Windows NT 4.0. and included in XP, Vista and Windows 7. This section lists some of KeyTweak’s features and reasons you may want to use KeyTweak.

Archive: Manual and Installer Here


***Other Information:***

Microsoft Documentation and Links

  • Archive: Microsoft - Keyboard Scan Code Specification Document
  • Archive: Microsoft How to Disable the Keyboard Windows Key
  • thewindowsclub - How to Disable the Keyboard Windows Key
  • Archive: Microsoft Keyboard Layout Creator 1.4

Links originally from SU Answer


What Does the Action Key Mode via Bios Do?

This setting changes the default behavior of the top buttons on the laptop keyboard. What does it mean?

If “Action Keys Mode” is set to “Enabled”, then to use additional features that are displayed as icons on the top row of the keyboard, you do not need to hold down the Fn key. It needs to be clamped so that the upper buttons work like F1..F12.

In the case when “Action Keys Mode” is in the “Disabled” position, as is often the default, the top buttons will work as standard F1 ... F12, and to use their advanced functions, depicted as icons, you need to additionally clamp Fn.

Source: Translation of Russian HelpAdmins.ru Article


**Further Reading**
  • SO - Remap Keyboard Combinations, Not Just Single Registry Values
  • Wikipedia - Fn Key
  • Wikipedia - Scancode
  • Wikipedia - Meta Key
  • Change Function key behavior in Dell laptops
  • How to Disable the Fn Key on a Laptop
  • SU - Swap the “fn” use of Function keys on a generic Keyboard in Linux
  • SU - How To Map Fn+Key (Multiple Keys) To Other Key in Windows?
  • Where to Find Windows Keyboard Scancode Registry Information?
  • Remapping the Fn Key in Ubutnu
  • Remapping shifted function keys in XKB - Unix
  • Linux And Samsung Series 9 Laptop Fn Keys

SHIFT + F10.

The right-click keyboard shortcut is to hold down SHIFT and then press F10. This is an alternative in caseright-click / context menu button is not available.