Saturday, October 5, 2019

macos - fn modifier ignored for F-key keyboard shortcuts in Mavericks

I've tested this on two machines running Mavericks (10.9.4), with and without an external keyboard, and in all cases the behavior is as described below.


Under System Preferences > Keyboard > Shortcuts in the "Mission Control" section I've enabled the "Show Desktop" shortcut and assigned it to F5. Similarly, I've assigned "Show Dashboard" to F6.


Regardless of how "Use all F1, F2, etc. keys as standard function keys" is set, the fn key is ignored for these shortcuts and the shortcut action always occurs, making it impossible to get F5 and F6 to act "normally" (such as in Terminal.app). It is worth noting that the "default" shortcut keys (e.g. F3 for Mission Control, F4 for LaunchPad) do work with fn as desired/expected: holding the fn modifier while pressing those keys "flips" the behavior (depending on how the "Use all F1, F2, etc. keys" option is set).


I installed "KeyRemap4MacBook" (now called Karabiner) and enabled keyboard event debug logging with:


sudo sysctl -w keyremap4macbook.debug=1

F5 without fn key


Jul 17 09:07:54 KeyboardEventCallback [sending]: eventType 10, flags 0x00000000, key 0x0060, kbdType  46, repeat = 0
Jul 17 09:07:54 KeyboardEventCallback [sending]: eventType 11, flags 0x00000000, key 0x0060, kbdType 46, repeat = 0

F5 with fn key


Jul 17 09:07:58 KeyboardEventCallback [sending]: eventType 12, flags 0x00800000, key 0x003f, kbdType  46, repeat = 0
Jul 17 09:07:59 KeyboardEventCallback [sending]: eventType 10, flags 0x00800000, key 0x0060, kbdType 46, repeat = 0
Jul 17 09:07:59 KeyboardEventCallback [sending]: eventType 11, flags 0x00800000, key 0x0060, kbdType 46, repeat = 0
Jul 17 09:08:01 KeyboardEventCallback [sending]: eventType 12, flags 0x00000000, key 0x003f, kbdType 46, repeat = 0

And for comparison...


F1 without fn key


Jul 17 09:09:11 KeyboardEventCallback [sending]: eventType 10, flags 0x00000000, key 0x0091, kbdType  46, repeat = 0
Jul 17 09:09:11 KeyboardEventCallback [sending]: eventType 11, flags 0x00000000, key 0x0091, kbdType 46, repeat = 0

F1 with fn key


Jul 17 09:09:16 KeyboardEventCallback [sending]: eventType 12, flags 0x00800000, key 0x003f, kbdType  46, repeat = 0
Jul 17 09:09:17 KeyboardEventCallback [sending]: eventType 10, flags 0x00800000, key 0x007a, kbdType 46, repeat = 0
Jul 17 09:09:17 KeyboardEventCallback [sending]: eventType 11, flags 0x00800000, key 0x007a, kbdType 46, repeat = 0
Jul 17 09:09:19 KeyboardEventCallback [sending]: eventType 12, flags 0x00000000, key 0x003f, kbdType 46, repeat = 0

Notice that with F1, when the fn key (key code 0x3F) is down, the key code is 0x7A ("F1") instead of 0x91 ("BRIGHTNESS_DOWN"), but for F5, the key stays 0x60 ("F5").


It seems that whatever is handling the keyboard shortcuts prefpane doesn't have a way to include the state of the fn modifier.


So here's my question: is there some way to assign keyboard shortcuts to function keys so that they work like the default system shortcuts and honor the fn key as a toggle between "normal" and "shortcut" behavior?

No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...