ShikiSuen
(ShikiSuen)
1
The InputMethodKit of macOS allows using NSEvents to parse key signals and handle them.
However, Shift key appears to have no keycode.
Is there a way to handle Shift key pressing signal to allow using it to toggle a bool switch?
1 Like
tera
2
Shift and other modifier keys are stored in modifierFlags of NSEvent.
1 Like
ShikiSuen
(ShikiSuen)
3
Thanks for your response.
However, this only works for detecting whether Shift key is being "hold".
I want to detect a key release event.
johnfairh
(John Fairhurst)
4
Probably NSEvent.addLocalMonitorForEvents(matching:handler:) -- but this is really a question about apple frameworks rather than the Swift language and is better asked on the apple forums.
3 Likes