objective c - Accessing Keyboard API -
i looking intercept keyboard events in mac app.
i user initiate "record" activity copy keystones , "stop" activity.
is possible via cocoa's mac api?
have @ nsevent method addlocalmonitorforeventsmatchingmask:handler:. allow receive events (specifically keydown events in case) occur in app, , can whatever want keystrokes method returns. here simple example of how use method:
self.keystrokes = [nsmutablestring string]; [nsevent addlocalmonitorforeventsmatchingmask:nskeydownmask handler:^nsevent* (nsevent* event){ nsstring *keypressed = event.charactersignoringmodifiers; [self.keystrokes appendstring:keypressed]; return event; }];
Comments
Post a Comment