JDK-4342184 : In Windows, arrow keys throws Invalid key code exception when pressed by robot.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: solaris_7
  • CPU: sparc
  • Submitted: 2000-05-31
  • Updated: 2001-08-16
  • Resolved: 2001-07-18
Related Reports
Relates :  
Relates :  
Description
In Windows,Invalid Key Code exception was thrown for Up, Down, Right, Left arrow keys when pressed using robot.

How to reproduce the Bug? -------->
Run this sample code. You would see a frame with a red Canvas.This is an automated test. No user interaction allowed.The robot will press the different arrow keys.If key events are triggered, the message will be displayed on the text area.

	If Invalid Key Code exception is thrown , the bug is reproduced.

Comments
EVALUATION Probably a duplicate of 4106941. eric.hawkes@eng 2000-07-05 The exception thrown is actually a java.lang.IllegalArgumentException. Problem: it doesn't seem to be succeeding on Solaris, either. No events are being produced. xmodmap -pke reveals that no keys are mapped to XK_KP_Up, etc. The numpad keys are mapped to XK_Up, etc., which is probably sabotaging the key events. In other words, I would bet that no key event is being generated, since there is no key on the keyboard that is mapped to that keysym. Output from xmodmap -pke keycode 31 = Left keycode 98 = Left F30 KP_4 And in fact, when I press the distinct Left arrow, I get: keycode=31, keysym=65361=0xff51 - XK_Left When I press the numpad left arrow, I get keycode=98, keysym=65361=0xff51 No modifiers - XK_Left keycode=98, keysym=65499=0xffdb Shift only - XK_F30 keycode=98, keysym=65460=0xffb4 NumLock only - XK_KP_4 After executing xmodmap -e "keycode 98 = KP_Left" the test passes for VK_KP_LEFT. Mystery solved. eric.hawkes@eng 2000-08-25 The problem on windows seems to be that we aren't using the public static final int VK_KP_UP = 0xE0; public static final int VK_KP_DOWN = 0xE1; public static final int VK_KP_LEFT = 0xE2; public static final int VK_KP_RIGHT = 0xE3; keys in awt_Component.cpp - they don't exist in our mapping table. We need to check the extended bit, which is turned on for the distinct arrow keys. eric.hawkes@eng 2000-08-26 Unfortunately, we can't fix this correctly without introducing a backwards incompatibility. So, we'll have to live with the incompatibility between Unix and Windows. However, we can provide new APIs that allow users to distinguish between numpad and standard keyboards. See 4424517. We'll probably have to close this as Will Not Fix. Please see my email to tina.su@eng on this subject in the Comments section. eric.hawkes@eng 2001-03-18 This is an incompatibility between the Unix and Windows implementations. Unfortunately, we can't fix it without introducing a backwards incompatibility. The only solution we could come up with was to add new APIs to deal with this situation. See 4424517. eric.hawkes@eng 2001-04-13 Closing, for the reasons described above. No more can be accomplished on this issue. eric.hawkes@eng 2001-07-17
13-04-2001