Christopher Bull
Christopher Bull

Reputation: 2629

How can you fire a 'Media Key' event in Java?

Media keys can be hardware or vendor specific, unlike the normal keyboard keys, so they do not appear to be widely supported - especially in the JDK.

Regardless, can a media key event be fired within Java so that an open media player will respond as if the user has pressed the Play/Pause button on their keyboard, thus enacting a play/pause on the current media?

If no Java specific answers are available, I would still be interested to see any solutions for non-platform independent languages.

All the best.

Upvotes: 3

Views: 1836

Answers (1)

HectorLector
HectorLector

Reputation: 1911

You can use JNI to call a small C Function or maybe you can use the Java Robot class.

Have a look at:

Simulate a Keypress WinAPI - keybd_event

List of Virtual Keycodes

Upvotes: 2

Related Questions