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?
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?
Shift and other modifier keys are stored in modifierFlags of NSEvent.
Thanks for your response.
However, this only works for detecting whether Shift key is being "hold".
I want to detect a key release event.
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.