JDK-4474756 : Underscore input impossible with Robot Class (for Japanese Keyboards)
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.3.1,1.4.2
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: windows_98,windows_2000
  • CPU: x86
  • Submitted: 2001-06-26
  • Updated: 2006-03-06
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Description

Name: yyT116575			Date: 06/26/2001


java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)

Japanese keyboards have two keys which both produce a backslash character.
Usually, one is labeled with a yen symbol, and the other with a normal
backslash.  Pressing shift, however, produces different results.  Pressing
shift with the yen key will produce a pipe symbol, while the other will
produce an underscore.

Currently, with the Robot class, if a Japanese keyboard user does

Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_SHIFT);
robot.keyPress(KeyEvent.VK_BACK_SLASH);
robot.keyRelease(KeyEvent.VK_SHIFT);

The output will be a pipe character.  KeyEvent does not distinguish between the
two backslash keys, so it seems impossible to enter an underscore.

Suggestion: add a KeyEvent.VK_YEN, pressing shift should return a pipe for it.
Then VK_BACKSLASH should return underscore with shift.
(Review ID: 127361) 
======================================================================

Comments
EVALUATION This is indeed a problem. A solution would involve additions to KeyEvent and possibly Robot. ###@###.### 2003-04-25 The problem is that both the yen sign and the back-slash share the same codepoint. When debugging a native windows application, I saw that pressing the yen sign (0xDC -> VK_OEM_5) and pressing the backslash key (0xE2 -> VK_OEM_102) both produced charCodes of 92 for the WM_CHAR message. The yen sign had a scancode of 7D while the backslash key had a scancode of 73. When we build the dynamic key table for the OEM keys, both get mapped to ANSI and unicode values of 5C. Thus, both are mapped to the Java keycode VK_BACK_SLASH. As a result, Robot cannot make a distinction between the two, and always chooses the first one it finds (the yen key). Thus, it can only press the yen key, never the slash key. I don't think we can change this now, e.g. by adding a new keycode KeyEvent.VK_YEN, because we have always generated VK_BACK_SLASH for this key in the past. It would be an incompatibility. I wonder if a good solution would be to assign different locations to the two backslash keys (back slash and yen), and add an API to Robot to press the left or right key. All of the above is on a Japanese windows keyboard. I should also try this on a Japanese Solaris keyboard (and on linux as well?) before arriving at a solution. ###@###.### 2003-04-28
28-04-2003