Running code when play/pause button, skip, etc. on bluetooth keyboard pressed

Hello,


Is there any way to, in Swift, run a function perhaps by setting up a target or something for when an external bluetooth keyboard play/pause butotn is pressed. It would also be nice to know about the skip forward and backward buttons. I know there is such thing as a UIKey, but ther eseems to be no option for keyboard buttons other than characters and arrow keys.


Does anyone know how to do this? Thanks in advance. Any help is appreciated.

Replies

Try MPRemoteCommandCenter. I know it responds to Control Center controls and external acessories. I'm not sure if it responds to keyboard buttons, but it's worth a try.