How can I use key events only on a keyboard with a specific HID in Mac OSX?

Possible duplicate:
OSX HID filter for secondary keyboard?

I would like to write a Mac OSX application that captures keyboard events on a second keyboard and consumes them before other applications receive a notification? I do not have an application that will be notified of a key press on the keyboard of the main computer, but only on the second. And I do not want other applications to receive a keystroke, I want to use it. Does anyone here know a better way to do this?

+6
source share
1 answer

For this you need IOKit. The code will include writing kext and capturing keyboard events and choosing whether to pass them to user space. Writing the whole approach here would be too complicated and big, but I can offer a few links.

KeyRemap4MacBook code has a fairly low low-level code to read and intercept the device.

Here is the user kext that the author wrote: https://github.com/tekezo/KeyRemap4MacBook/tree/master/src/core/kext

I suggest you familiarize yourself with the code to find out how it intercepted the keys, reassigned them according to the user configuration, and sent them to the user space.

0
source

Source: https://habr.com/ru/post/904646/


All Articles