Page 1 of 1

Previous/Pause-Play/Forward keys

Posted: 28 Nov 2008 19:48
by wubrgamer
Do these keys (f7/f8/f9) work on Mac OS X ?

Or did Apple lock them down for their own applications (iTunes) only? I prefer VLC to be honest, but I'd like to use these keys as well, is this possible?

Re: Previous/Pause-Play/Forward keys

Posted: 21 Dec 2008 21:20
by wubrgamer
It was mentioned in IRC that these keys work under Ubuntu. So it is possible for Mac OS X as well, is there just no interest in implementing this feature?

Re: Previous/Pause-Play/Forward keys

Posted: 24 Dec 2008 02:30
by zacwest
There's some information about the media keys at the Rogue Amoeba blog, but the method spoken about in the blog requires VLC to have focus. The event tap found in the comments is where the real solution lies:
So I gave it a try, and sure enough it works: You can tap media key events by doing something along the lines of:

Code: Select all

CGEventTapCreate(kCGSessionEventTap, kCGHeadInsertEventTap, options, CGEventMaskBit(NX_SYSDEFINED), tapSystemDefinedEvent, NULL);
This requires universal access (via its system prefpane) being enabled, which isn't entirely unreasonable to ask; a lot of applications require it for shortcut access these days.

It would be phenomenal for VLC to have the media keys working; if the source wasn't such a daunting task I'd probably give it a shot.

If you're looking for working example code of the NSApplication subclassing method, I wrote a small patch for NicePlayer which accomplishes it; it's a pretty simple method, but it requires application being keyed to receive the actions.