I am looking to intercept keyboard events in a Mac app.
I would like the user to initiate a “record” activity which will copy the keystones and then a “stop” activity.
Is that possible via Cocoa’s Mac API?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Have a look at the NSEvent method addLocalMonitorForEventsMatchingMask:handler:. This will allow you to receive events (specifically keyDown events in your case) that occur in your app, and you can then do whatever you want with the keystrokes that the method returns. Here is a simple example of how to use that method: