Control using bluetooth devices

I need the application to receive commands from a wireless headset, in the same way that when I click on the headset the music stops, I need the application to do something when I click on the headset.

Is there any extension for this?