3

I've used this python script to disable iTunes from launching when one of the media keys has been pressed. However, when I want to use it with Spark it doesn't respond to the media keys as input for a hotkey.

Basically it doesn't have to be Spark, but I'd like to map shell commands to my mediakeys instead. How can I do this?

Thanks! Dennis

3 Answers 3

3

You can't. They are intercepted before any application can register that a key has been pressed. The python script replaces the actual iTunes binary because there's no other way to do this!

You don't get an additional 12 keys by (not) pressing Fn.

(they also cannot be pressed programmatically, e.g. AppleScript's key code or keystroke commands!)


If you don't use the F-keys otherwise, consider using them (instead of media key functionality).

enter image description here


To use some keys as standard function keys, others as media/special keys, use FunctionFlip.

1
  • Daniel Beck is the winner! Works great for me :D
    – FLX
    Commented Feb 10, 2011 at 23:59
1

You can do this with Karabiner. It's a somewhat involved process that involves writing a custom XML configuration file, but I was able to get it to work for the media keys on my Bluetooth keyboard (Kinesis Freestyle 2), for which FunctionFlip wouldn't work.

For example, here's the part of my configuration file that maps the Play/Pause button to F6:

<item>
  <name>Music_Play to F6 on Kinesis Freestyle2</name>
  <identifier>private.f6</identifier>
  <device_only>DeviceVendor::KINESIS, DeviceProduct::FREESTYLE2</device_only>
  <autogen>__KeyToKey__ ConsumerKeyCode::MUSIC_PLAY, KeyCode::F6</autogen>
</item>

There's also syntax for having keys trigger shell scripts or URLs.

1
  • Kanabiner is awesome, but it still doesn't see ALL the media keys. On my Adesso WKB-5400UB, it only sees a few of them above the F6-F12 keys. And the power key works, but cannot be re-mapped. Commented Mar 13, 2022 at 6:02
-1

Yep, you can. Here's a google translate page explaining it, from Lifehacker.

1
  • This patches a core service to not dispatch a call to iTunes. He doesn't get freely assignable keys this way, which is what the question is about.
    – Daniel Beck
    Commented Feb 11, 2011 at 20:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .