Wish list: add Fn (Globe 🌐) as a modifier to use as hotkey or USB Key trigger. Is there a workaround in the meantime?

I would like to use the Fn key the same way one can use other modifiers, for example just like ⌃A, I could type :globe_with_meridians:A, etc

It must be possible because within the Mac OS (in settings → Keyboard Shortcuts → Mission Control of Ventura 13.6.7) there is a Mac OS native Keyboard Shortcut :globe_with_meridians:Q which allows me to open a quick note in apple notes.

Is there a workaround I could use in the meantime ?

If I type :globe_with_meridians:A in the hotkey trigger field, the :globe_with_meridians: is not registered.

It would also be nice if KM distinguished the modifiers on the left and right side of the keyboard.

thanks in advance for your time and help

Screenshot (click to expand/collapse)

KM can do that. I think with the USB device triggers. There are example macros in this forum. But don't ask me where :rofl:

Fn as modifier works with BTT. A workaround with KM would be to swap fn with right control in macos.

1 Like

See "Can I use the Fn key as a modifier?" in the FAQ.

More information can be found in this discussion on GitHub. Some of the replies towards the end of the thread are perhaps the clearest about the issues.

1 Like

I note with interest that Keyboard Cowboy, which was mentioned today in the forum, places great emphasis on using the fn key for shortcuts. Anyone who uses an Apple keyboard (internal or external), or a limited number of other brands of external keyboards (some faking the vendor ID to make things work) will be ready to go. For every one else, some hacking is required.

I find the permutations of shift, control, option and command modifiers to be ample (although, for convenience, I do use key-activated "layers" in the configuration for my QMK-programmable keyboard, and those keys could be regarded as extra modifiers!).

1 Like

thank you very much @kevinb and @Frankb !

2 Likes

how would I do that ? thank you

I don't know if that will help you. It only makes sense if your keyboard does not have a control key on the right-hand side. Below is an explanation for Caps Lock but with fn it works the same. So you have left/right control side by side and you can use both modifiers for separate shortcuts. As far as I know, the modifiers can even be combined, i.e. left + right control + letter. I hope I'm not talking nonsense :innocent:

1 Like

Generally speaking, KM lets you do whatever macOS public API's allow it to do. If KM doesn't distinguish between left and right modifiers, that's probably because the API doesn't allow KM to do it, not because the Architect of KM is denying you some functionality. There are many other utilities that use undocumented APIs to solve difficult problems. These products often break as the undocumented APIs change. As a result of this philosophy, I think KM macros that are 15 or more years old will still run today. Sometimes I feel like you, that I'd like to see more power, but I generally just accept that KM gives you all the power that macOS officially and publicly provides.

2 Likes

To clarify, neither the Globe nor the Fn key are real modifiers, not in the sense that Control, Command, Shift and Option are (and to a degree, Caps Lock).

The system Hot Key API does not use any modifiers except the 4 standard ones, and does not distinguish between the left and the right modifiers. So that is what Keyboard Maestro uses for Hot Keys.

Traditionally, the Fn key acted more like a hardware toggle - the physical key on the keyboard was like two different keys, a hardware key (eg Volume Up) and a function key (eg F3), and then Fn key toggled between them.

These days Apple is doing weird things with the Fn key, including using them in menus. But as far as I am aware, that is an Apple-only thing, and not something that has changed any part of the hot key API.

Keyboard Maestro can detect most of these keys, including left and right modifiers, using the USB Device Key trigger. This is an entirely different process that looks at (but does not affect) low level USB events for button presses (technically, for value changes that turn on a single bit and then turn it off).

So yeah, I wish the Fn/Globe key could be used as a hot key modifier, and that hot keys could optionally distinguish left and right modifiers, but as far as I am aware, that is not possible with the system API. Maybe it will be one day, but Apple unfortunately does not seem to have a mindset of "We are going to add feature X, lets start with a public API, and then build out feature on that".

4 Likes

I noticed that KM can generate key events using FN as a modifier. For instance, I'm able to generate Fn+F keystrokes in KM to zoom a window. But Apple still doesn't support detecting it? How does that work?

1 Like

The Fn/Globe key's up/down status is not even visible to macOS, as its very existence appears only inside the keyboard's firmware.

Can you show your macro? I don't know what you mean by that.

1 Like

to my surprise, this works.

Upon further investigation, One doesn't even need to type an unmodified "F" and then select "Function" under modifiers. One can also type a Fn+F in that field, and KM correctly records it.

2 Likes

I never even looked at that option before. I'm such a noob.

In any case, the answer remains... you can't detect "Fn" as a modified because it's baked into the firmware of the keyboard to generate unique USB Device Key values. But that doesn't stop macOS from letting an app like KM generate those values.

2 Likes

to be pedantic. (because, why stop now.. : )

KM certainly detects the Fn key. As I mentioned, you can see that by:

  • add a macro action, "Type a keystroke"
  • hold down function key, and type a key, eg. Fn + I
  • see that KM records a key
  • click the dropdown next to the field, as in my screen cap above.
  • see that "Function" is checked. That's KM setting the checkmark.

I tested on internal & external keyboards.

I'm not disputing Peter that Apple notoriously uses APIs that aren't available to devs. But taking a little peek in the API for Appkit:NSEvent...

  public struct ModifierFlags : OptionSet, @unchecked Sendable {

        public init(rawValue: UInt)

        public static var capsLock: NSEvent.ModifierFlags { get }

        public static var shift: NSEvent.ModifierFlags { get }

        public static var control: NSEvent.ModifierFlags { get }

        public static var option: NSEvent.ModifierFlags { get }

        public static var command: NSEvent.ModifierFlags { get }

        public static var numericPad: NSEvent.ModifierFlags { get }

        public static var help: NSEvent.ModifierFlags { get }

        public static var function: NSEvent.ModifierFlags { get }

        public static var deviceIndependentFlagsMask: NSEvent.ModifierFlags { get }
    }

edit/ps: "help" ? is a modifier key??

1 Like

Fair point. I can't argue at that level.

1 Like

There is a difference between simulating a keystroke and registering a hot key.

The latter is done using the RegisterHotKey API, and for it the modifier flags are defined thusly in Events.h:

typedef UInt16                          EventModifiers;
enum {
                                        /* modifiers */
  activeFlagBit                 = 0,    /* activate? (activateEvt and mouseDown)*/
  btnStateBit                   = 7,    /* state of button?*/
  cmdKeyBit                     = 8,    /* command key down?*/
  shiftKeyBit                   = 9,    /* shift key down?*/
  alphaLockBit                  = 10,   /* alpha lock down?*/
  optionKeyBit                  = 11,   /* option key down?*/
  controlKeyBit                 = 12,   /* control key down?*/
  rightShiftKeyBit              = 13,   /* right shift key down? Not supported on Mac OS X.*/
  rightOptionKeyBit             = 14,   /* right Option key down? Not supported on Mac OS X.*/
  rightControlKeyBit            = 15    /* right Control key down? Not supported on Mac OS X.*/
};

That is not to say there are not additional bits defined somewhere else, maybe there are, but I am certainly not aware of them.

1 Like

thanks for the reply Peter. Ahhh.. I think I get it now.
-The flags I posted are for a standard key event that apps see. (which I tested - yes a new bit is set in ModifierFlags when I held down Fn)
-KM can see the Fn modifier within the KM editor app - via that api.
-But KM doesn't see every event in every app - for outside apps it only gets "hotkey" events. which don't include Fn modified.
-but it can generate Fn-modified events.

simple.

this actually came up in configuring Steermouse - I wanted it to send a Fn+F. But it doesn't include an option for adding a Fn modifier. Yet KM does.
(hence function modifier rabbit hole...)
Solution: Steermouse generates an intermediate code which triggers a KM macro which sends Fn+F. works like a charm. I do appreciate how well Steermouse & KM work together.

2 Likes