title: Capturing media keys (play/pause) in OSX
body: <p><strong>The research, the problems, the mid-age crisis</strong></p>
  
  <p>There are some questions <a href="https://stackoverflow.com/questions/2477068/listening-to-mac-keyboard-play-pause-events">here</a> and <a href="https://stackoverflow.com/questions/2477068/listening-to-mac-keyboard-play-pause-events">there</a> about capturing the play/pause events. The solution usually relies on extending <a href="http://joshua.nozzi.name/2010/10/catching-media-key-events/" rel="nofollow noreferrer">NSApplication</a> and capturing the sendEvent. However, there are two problems with that: The iTunes opens OR some apps capture it before (Spotify I am looking at you).</p>
  
  <p><strong>Damn you spotify</strong></p>
  
  <p>More people were bored with iTunes opening using the play/pause, and <a href="https://stackoverflow.com/questions/11437058/binding-to-media-keys-block-itunes-os-x">posted in the stackoverflow</a>. However, <a href="http://overooped.com/post/2593597587/mediakeys" rel="nofollow noreferrer">the solution</a> still gets beaten by spotify (and it relies on a strange whitelist). If I open the example and press one of the mediakeys spotify catches the event and that solution doesn't.</p>
  
  <p>How can I <strong>defeat</strong> Spotify and capture media events?</p>