I have a problem with OS X detecting keystrokes. I need to detect a key down and a key to unlock a key or key whenever a keyboard key is pressed. This is pretty straight forward if you intercept the application event processing chain using [ NSEvent addLocalMonitorForEventsMatchingMask: handler: ] . This allows you to intercept and modify NSEvent for various types of events, including NSKeyUp and NSKeyDown for regular print keys, as well as NSFlagsChanged , which can be used to detect shift, ctrl, alt and CMD. In fact, since the modifier flags change both up and down for the shift, ctrl, alt and cmd NSFlagsChanged , NSFlagsChanged can be used as a key and key event for these keys by checking [NSEvent modifierFlags] along with [NSEvent keyCode] .
Kapslok is different, however. Since the caplock modifier really only acts on the down key when you press capslock, you only get NSFlagsChanged with a click on the button, not when it is released. Both NSKeyUp and NSKeyDown not highlighted using modifier keys such as caplock and shift and ctrl, etc.
Can someone suggest a way, and maybe even a lower-level interface, for receiving events with closing the lock? Should I resort to using kqueues or something else?
source share