I would like to filter keyboard input on a second keyboard, and prevent the key events for that second keyboard from reaching the OS (handle them myself). How can this be done?
Share
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.
It can be done by using IOKit and the HIDManager class.
If exclusive access to the keyboard is desired, the
kIOHIDOptionsTypeSeizeDeviceoption can be used, but the program will have to be run with root privileges.A stub of the code required to obtain this result is shown below:
More detailed information can be found in the Apple docs over here: http://developer.apple.com/library/mac/#documentation/DeviceDrivers/Conceptual/HID/new_api_10_5/tn2187.html
The complete code I used for my application can be found here:
https://gist.github.com/3783042