Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to capture fn key #31

Open
torywalker opened this issue Jan 27, 2021 · 2 comments
Open

Unable to capture fn key #31

torywalker opened this issue Jan 27, 2021 · 2 comments

Comments

@torywalker
Copy link

Setup

macOS: 11.0.1
HotKey: 0.1.3
Deployment Target: 10.15
XCode Version: 12.3

Issue

I seem to be unable to capture the fn key with HotKey when looking at the modifierFlags.

let carbonKey = UInt32(event.keyCode)
let carbonFlags = event.modifierFlags.carbonFlags

self.hotKey = HotKey(keyCombo: KeyCombo(
    carbonKeyCode: carbonKey,
    carbonModifiers: carbonFlags
))

I also tried passing the modifierFlags directly:

let carbonKey = UInt32(event.keyCode)

self.hotKey = HotKey(keyCombo: KeyCombo(
    key: Key(carbonKeyCode: carbonKey)!,
    modifiers: event.modifierFlags
))

When recording a shortcut with the fn pressed, it seems to omit fn from what is stored.
Executing the recorded shortcut with fn pressed also does not activate the shortcut (it does work when omitting fn key).

When describing the stored shortcut, the fn key, it is absent:

self.hotKey?.keyCombo.description

However, performing the following check prior to storage indicates that the fn key is indeed present

if (event.modifierFlags.contains(.function)) {
    // this evaluates to true
}

Is there anything I'm missing? Is this unsupported?

@tybug
Copy link

tybug commented Feb 6, 2021

Same issue here. A workaround would be appreciated if anyone finds one.

@luser
Copy link

luser commented Jun 23, 2021

I tried using this to capture Fn+Space (I bought a new keyboard that has a "Microphone" key that sends that combo.) and similarly wasn't able to:

let hotKey = HotKey(key: .space, modifiers: [.function])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants