kwhat/jnativehook

GetKeyCode() Always Returns 0

r6dev opened this issue · 5 comments

r6dev commented

Whenever I call e.getKeyCode() I always get '0' in return, so I can not use NativeKeyEvent.getKeyText() or anything that utilizes the this.keyCode variable. Is there any fix to this?

kwhat commented
r6dev commented

Use KeyTyped events? Do you mean something separate from what I'm already using?

r6dev commented

And by that I mean I am already using a nativeKeyTyped event, yet it still returns 0

kwhat commented

Key Typed events produce characters and press/release events produce codes. So if you are listening for key typed, use e.getKeyChar() to get the ASCII representation that was produced. Key down events are fired fight before key typed events and use e.getKeyCode() to get the key code which may or may not be the same as the ASCII char. This should be the same as how key events work in Java.

r6dev commented

Wow thank you so much, the problem is fixed now