Mac OSX DDHotKey for Play/FF/Rewind Buttons

169 views Asked by At

I'm working on an OSX app with DDHotKeyCenter to control youtube/pandora song playbacks and would like to use the Mac play/pause, rewind, and FF buttons; however, they only seem to be accessible by calling the function key that they are mapped to (e.g., 'play' button maps to F8, so user has to hit "fn"+play/F8 button). Ideally, I'd like the user to just be able to hit play instead of having to do a combo.

Is there any way to hook into the play/rewind/FF buttons without the F8 keys? Creative solutions welcome! I'm coming from iOS background so OSX is a bit new to me..

Thanks!

1

There are 1 answers

2
Ken Thomases On BEST ANSWER

Whether the hardware buttons require the use of the "fn" key or not is controlled by user preferences. See System Preferences > Keyboard pane > Keyboard tab > Use all F1, F2, etc. keys as standard function keys. If that is checked, then the F8 key produces a key event for, well, the F8 key. In order to access the hardware function (e.g. Play/Pause), the user has to hold down "fn".

If that preference setting is not checked, then the behavior is reversed. The F8 key does Play/Pause by default and the user has to hold down "fn" to get a key event.

By the way, third-party keyboards can't access the hardware functions in the same way that Apple keyboards do. So, don't write an app that depends on them being available.

The hardware functions can't be trapped as hot keys. They are intercepted at a low level by the keyboard driver. I have a vague recollection of some very hacky approach to hijacking them, but it won't work to treat them as hot keys.

So, what you're probably finding is that you're able to set up F8 as a hot key for your app's functions, but, since your preference settings are configured so that the F8 key event is only generated when you press fn+F8, you have to use that combo. Pressing the F8 key by itself is generating a hardware function operation which is not visible as a key event.