Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to intercept music control keyboard shortcuts in Java?

Tags:

If your keyboard has buttons for play/pause/etc (music control shortcuts), and you press them, iTunes will open (at least on Mac).

If you recently opened another music player, like Spotify, it will actually intercept the shortcut keys, and iTunes won't do anything.

Well, I want to make a music player with Java, and I want to have the same behavior. I want my application to intercept such shortcuts, and other programs shouldn't be able to interfere.

I am using JavaFX, although I don't think that really matters.

How can I achieve this?

I am already able to detect they keys the user presses using JNativeHook, but I do not know how to intercept the keys so that other applications won't do things with them.