I am trying to detect system wide keyboard inputs for my mac application. To do so I am using the below code:
[NSEvent addGlobalMonitorForEventsMatchingMask:NSEventMaskKeyDown
handler:^(NSEvent *event) {
NSString *eventChars = [event characters];
unichar keyChar = [eventChars characterAtIndex:0];
NSLog(@"keyboard char is %c",keyChar);
}];
While this works perfectly and tracks keyboard input entered anywhere on Safari, the handler does not get triggered only if user tries to enter password in any web page (ex: password box in facebook login page, any login page with password box).While the username input can be tracked the password input cannot.
Is this the expected behaviour or am I missing something because this works perfectly with Chrome. All keyboard inputs can be tracked with the global monitor incase of Google Chrome.But fails only for this particular case in Safari.