Snarfing Keyboard Events
Snarfing Keyboard Events
- Subject: Snarfing Keyboard Events
- From: Seth Willits <email@hidden>
- Date: Sun, 7 Oct 2007 15:17:17 -0700
Howdy,
In my application I need to be able to intercept keyboard events from
the entire system. The Carbon path using GetEventMonitorTarget()
sorta works except that it fails to intercept events for hot keys
setup with RegisterEventHotKey, nor does it catch certain system-
handled keyboard shortcuts like Cmd-Shift-3. Another issue is that I
also (at times) need to be the sole listener of a particular event.
Hot keys work great except that it can have multiple listeners (for
example, installing a hot key for Cmd-Shift-3 still allows the system
to use it to take a screenshot). So the only option I know to deal
with all of these problems is using an event tap.
Creating an event tap is easy and you can filter out events, so it
works perfectly for me, though the biggest issue with using it is
that either your app has to be running with root access, or "Enable
access for assistive devices" must be turned on in Universal Access.
I can accept that if it's the law, though I have a feeling it isn't
the law because of Snapz.
Snapz certainly doesn't run as root, nor does it spawn a dedicated
root-run process, but even with "Enable access for assistive devices"
turned off, Snapz can happily capture Cmd-Shift-3 and block the
system and other applications from responding to it. Is there any
known way to do this? If I Shark Snapz I see it's responding to some
CGS method, so I'm reasonably confident it's using entirely private
methods, but I'm still curious.
Anyone have any info?
--
Seth Willits
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden