Raw code: 37
Key code: 57419
Key location: 1
Modifiers: 0
Raw code: 37
Key code: 57419
Key location: 1
Modifiers: 0
import org.jnativehook.GlobalScreen;
import org.jnativehook.NativeHookException;
import org.jnativehook.keyboard.NativeKeyEvent;
import org.jnativehook.keyboard.NativeKeyListener;
public class KeyEventDemo implements NativeKeyListener {
public static void main(String[] args) {
try {
GlobalScreen.registerNativeHook();
}
catch (NativeHookException ex) {
System.err.println(ex.getMessage());
System.exit(1);
}
GlobalScreen.addNativeKeyListener(new KeyEventDemo());
}
@Override
public void nativeKeyPressed(final NativeKeyEvent nativeKeyEvent) {
System.out.println("Key code: " + nativeKeyEvent.getKeyCode()
+ ", raw code: " + nativeKeyEvent.getRawCode());
}
@Override
public void nativeKeyReleased(final NativeKeyEvent nativeKeyEvent) {}
@Override
public void nativeKeyTyped(final NativeKeyEvent nativeKeyEvent) {}
}
@param rawCode the hardware code associated with the native key in this event.