18

I want to use Fn+S to emulate Ctrl+S, and so far this is my code:

 #InstallKeybdHook
 #Persistent

  SC126 & s::
     Send ^{s}
  return

My problem is that I don't know the Fn key's scan code.
How can I find it?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
user3098326
  • 219
  • 1
  • 2
  • 10
  • 3
    [Here](http://www.autohotkey.com/docs/KeyList.htm#SpecialKeys)'s how you can find scan codes for special keys. – MCL Jun 26 '14 at 13:38
  • Check out this [link](http://www.autohotkey.com/board/topic/27841-remapping-the-fn-key-a-solution/) – Karthik S Jun 27 '14 at 11:44
  • 2
    @Karthik Sampath the link you gave is for pressing specific "Key" to emulate "Fn + Another Key", while my question is how to use this "Fn + Another Key" to emulate specific "key". but anyway thanks for trying to help me. – user3098326 Jul 09 '14 at 14:25
  • @MCL thanks man, i've tried that , but it's not working, – user3098326 Jul 09 '14 at 14:32
  • Related (also about the "Fn" key and AutoHotkey): *[Sending a laptop's function keys in AutoHotKey](https://stackoverflow.com/questions/18491754)* – Peter Mortensen Feb 08 '23 at 21:40
  • The key scan codes for the 'Fn' key itself (unlike other modifier keys) may not even be available on the signal level (at least not in PS/2 mode). Are they trapped by the keyboard itself? And is some synthesised key scan code send out on the physical copper wire (or RF/wireless)? Isn't there a canonical Stack Overflow question for this? – Peter Mortensen Feb 08 '23 at 22:10

3 Answers3

42

The Fn key does not have a scan code.

The keyboard driver does not expose the Fn key to the operating system, so basically your operating system (and therefore AutoHotkey) does not know that it exists.

When you press the Fn key in combination with a supported key, the keyboard driver reports a single key press to the operating system with a different scan code. Basically, it tells the operating system that a different key was pressed.

Community
  • 1
  • 1
Michael
  • 1,263
  • 1
  • 12
  • 28
  • @Persona93 look at this page , that's what makes me question this, i wish i know how to know the scan code, i just need the scan code, that's all.http://stackoverflow.com/questions/18491754/sending-laptop-function-key-autohotkey?lq=1 – user3098326 Jul 09 '14 at 14:33
  • 1
    It seems that the person who posted that never got it working. They probably misunderstood what the scan key was for. I would suggest using the left windows key for hotkeys. It's right next to to Fn key and a quick Google search will tell you what the built in Windows key hotkeys are so you can avoid overriding them if you want to. – Michael Jul 09 '14 at 16:25
  • 1
    My mba 5,2 lists this under `evtest`: `Event: time 1644010787.861254, type 1 (EV_KEY), code 464 (KEY_FN), value 1 Event: time 1644010787.861254, -------------- SYN_REPORT ------------ Event: time 1644010787.957190, type 1 (EV_KEY), code 464 (KEY_FN), value 0 Event: time 1644010787.957190, -------------- SYN_REPORT ------------` So it does have a code when pressed alone, just not under X11. – Deanie Feb 04 '22 at 21:40
8

When you press the Fn key in combination with a supported key, the keyboard driver reports the presses to the operating system (Windows in this case).

You can find the Fn key scan code by:

  1. Go to the tray icon
  2. Right-click Script
  3. Click Open
  4. Click View and then Key History and Script Info (alternatively Ctrl + K)
  5. Once you press the key, you can refresh (F5) and scroll to the bottom to see the codes

See the attached screenshot Fn key

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Shailesh Singh
  • 131
  • 1
  • 3
  • 9
  • 3
    After you right click autohotkey icon you have to choose edit script, then add these lines: `#Persistent #InstallMouseHook #InstallKeybdHook while !(getKeyState("F1", "T")) KeyHistory return esc::exitapp` and choose reload script. Copy it from [here](http://superuser.com/a/1055167/137871) because it needs new line feeds which I can't enter in comments. To disable the history you can simply add `#KeyHistory 0`. – BornToCode Nov 08 '16 at 10:58
  • 1
    The "tray" icon refers to the system tray. Similar instructions [here](https://autohotkey.com/board/topic/15037-noob-get-scancode-of-pressed-key/), for redundancy in case anyone has trouble following the above. – Blue Raspberry Dec 29 '20 at 14:07
1

If you're trying to use a Mac keyboard and would like to map the Fn key to Insert (and also get other standard Windows keys, like PrintScreen), then you might want to try the 'hidfalum' driver. It's available here: http://www.bimoid.com/download/utils/hidfalum.zip

ishmael
  • 1,796
  • 3
  • 18
  • 19