Finding multimedia key key code in java

I want to capture keystrokes in Windows, such as Fn + Pause, Fn + VolumeUp in my Java application, but I cannot detect their KeyCodes.

addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { System.out.println(e.getKeyCode()); } }); 

Using this snippet, it prints 0 for all keystrokes on the multimedia keys!

Please offer a suitable method to search for keyCode and thereby use it in a Java application.

+1
source share
2 answers

Use the JIntellitype library.

This API is a Java JNI library that uses the C ++ DLL to interact with Windows. It also means that the platform you are running on must be Windows.

If you are using Linux, JXGrabKey

On MacOSX, use OSSupport

+3
source

Check KeyEvent constants for some special keys. Other special keys really cannot be "recognized".

See this thread.

0
source

All Articles