KeyPressed Undefined
Closed this issue · 7 comments
GoogleCodeExporter commented
What steps will reproduce the problem?
1. Global Keyboard Listener example at official page
2. Any combination of pressed keys
The example will output "Key Pressed: Undefined" for any key that I press. Key
Pressed and Key Released are ok.
I use JDK 1.7.0u10 64bit on Windows 7 64 bit
Original issue reported on code.google.com by roberto....@gmail.com
on 16 Jun 2013 at 7:51
GoogleCodeExporter commented
And I'm using the 1.1.4 release of JNativeHook.
Original comment by roberto....@gmail.com
on 16 Jun 2013 at 7:58
GoogleCodeExporter commented
Can you please be more specific? Do you mean that keyText=Undefined for key
typed events? For example:
"NATIVE_KEY_TYPED,keyCode=0,keyText=Undefined,keyChar='a',keyLocation=KEY_LOCATI
ON_STANDARD,rawCode=38"?
Original comment by a...@1stleg.com
on 16 Jun 2013 at 10:19
GoogleCodeExporter commented
For sure. I implemented the following straightforward method to print the
available output:
public void nativeKeyTyped(NativeKeyEvent e) {
System.out.println("Key Text "+NativeKeyEvent.getKeyText(e.getKeyCode()));
System.out.println("Mod Text "+NativeKeyEvent.getModifiersText(e.getKeyCode()));
System.out.println("Key Char "+e.getKeyChar());
System.out.println("Key Code "+e.getKeyCode());
System.out.println("Key Loc "+e.getKeyLocation());
System.out.println("Raw Code "+e.getRawCode());
System.out.println("Modif "+e.getModifiers());
}
I printed the output for some the keys in my "qwerty" keyboard. The output file
is in attach.
Please, let me know if you need some additional data.
Thank you
Original comment by roberto....@gmail.com
on 17 Jun 2013 at 7:57
Attachments:
- [keyboard output.txt](https://storage.googleapis.com/google-code-attachments/jnativehook/issue-52/comment-3/keyboard output.txt)
GoogleCodeExporter commented
This is more of a design choice than an issue. Please see paragraph 4 of the
documentation for NativeKeyEvent.
(http://jnativehook.googlecode.com/svn/tags/javadoc-1.1/org/jnativehook/keyboard
/NativeKeyEvent.html) "For NATIVE_KEY_TYPED events, the getKeyCode method
always returns VK_UNDEFINED." This is the same behavior you will get using
Oracle/Sun's KeyEvent implementation.
(http://docs.oracle.com/javase/7/docs/api/java/awt/event/KeyEvent.html) "For
key pressed and key released events, the getKeyCode method returns the event's
keyCode. For key typed events, the getKeyCode method always returns
VK_UNDEFINED. The getExtendedKeyCode method may also be used with many
international keyboard layouts."
If you have any questions, please let me know.
Original comment by a...@1stleg.com
on 17 Jun 2013 at 4:32
- Changed state: Invalid
GoogleCodeExporter commented
Thank you for the explanation: I was not aware of that! Honestly, I missed the
whole class description and I only read the method doc. However, I suggest to
update the description of the methods such that this fact is reported there.
Regards,
Roberto
Original comment by roberto....@gmail.com
on 18 Jun 2013 at 6:46
GoogleCodeExporter commented
No problem. Yah I agree, there seems to be some confusion regarding that
method from time to time. I will add an additional verbiage to the callback
method.
Original comment by a...@1stleg.com
on 18 Jun 2013 at 3:35
- Changed state: Accepted
- Added labels: Component-Docs, Priority-Low, Type-Other
- Removed labels: Priority-Medium, Type-Defect
GoogleCodeExporter commented
Original comment by a...@1stleg.com
on 16 Apr 2014 at 11:21
- Changed state: Invalid