How do I access (listen for) the multimedia keys (play/pause) in Mac OS X?
Asked Answered
S

3

8

I want to write a Songbird extension binds the multimedia keys available on all Apple Mac OS X platforms. Unfortunately this isn't an easy google search and I can't find any docs.

Can anyone point me resources on accessing these keys or tell me how to do it?

I have extensive programming experience, but this will be my first time coding in both MacOSX and XUL (Firefox, etc), so any tips on either are welcome.

Please note that these are not regular key events. I assume it must be a different type of system event that I will need to hook or subscribe to.

Sedative answered 22/9, 2008 at 12:27 Comment(0)
S
2

This blog post has a solution:

http://www.rogueamoeba.com/utm/posts/Article/mediaKeys-2007-09-29-17-00.html

You basically need to subclass NSApplication and override sendEvent,
looking for special scan codes. I don't know what songbird is, but if it's
not a real application then I doubt you'll be able to do this.

Or maybe you can, a simple category may suffice:

@implementation NSApplication(WantMediaKeysCategoryKBye)
- (void)sendEvent: (NSEvent*)event
{
    // intercept media keys here
}
@end
Ssw answered 8/1, 2009 at 7:42 Comment(0)
O
1

Are you sure your multimedia keys are working in your installation? Every single key generates a scan code which is translated into a key code by the kernel. If xev doesn't show you any keycodes I guess those scan codes aren't mapped and so the kernel has no knowledge of them.

http://gentoo-wiki.com/HOWTO_Use_Multimedia_Keys has a nice explanation of finding key codes and offers help on how you can find raw scan codes and translate them into key codes.

Otranto answered 25/9, 2008 at 19:1 Comment(0)
L
0

xev might help you if you want to find out which codes are being sent by multimedia keys.

Leatherjacket answered 22/9, 2008 at 15:2 Comment(1)
Thanks for the suggestion, but xev does not receive the multimedia key events. These are not normal key events, Ukulele for example is not able to receive or reassign them.Sedative

© 2022 - 2024 — McMap. All rights reserved.