Answer the question
In order to leave comments, you need to log in
How to distinguish pressing the "left" key from Num 4 with Num Lock disabled?
Greetings! I use jnativehook, but it's probably not the tool.
How can I distinguish between pressing Num 4 and pressing the left button with Num Lock off? Here's what I write about it in the log:
Raw code: 37
Key code: 57419
Key location: 1
Modifiers: 0
Raw code: 37
Key code: 57419
Key location: 1
Modifiers: 0
Answer the question
In order to leave comments, you need to log in
In my case, jnativehook returns the same keyCode, but the keyRawCode is different (version 2.0.2):
Example:
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.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question