views:

94

answers:

1

I want to use a foot pedal to press the key, but OS X won't associate a modifier keys across two different devices. I've found some applications that create virtual keyboards, such as synergy+, so I know it must be possible to capture events from 2 devices and merge them as if they were coming from one device. Any ideas on how I can make this happen?

A: 

Quartz Event Services allows you to create event taps that listen for events. You can register to listen for appropriate event types and then pass through a new event in place of the "real" event. Have a look at CGEventTapCreate in the Quartz Event Services manager reference.

This is a pretty low-level technique and it's easy to break things, so you need to be careful. In particular, when you tap into the event queue you can easily lock up your system when you run the code on the main thread and it crashes.

Rob Keniger