|
Description
|
I:\ip\jputre\java\osdi\keyboard\key1\src>java -version
java version "1.2.2"
Classic VM (build JDK-1.2.2-004, native threads, symcjit)
I:\ip\jputre\java\osdi\keyboard\key1\src>
On Windows NT, and win2000, non-standard keys generate a keyevent (keypress,
type, reelase) with a Keycode=0. Our application has ~ 160 keys. The KeyCodes
are seen by Windows, also seen by MS's VM (jview), but the SUN JVM sets the
KeyCode to 0 and there is no way for our app to act on the keys.
The problem is similar to BugId 4290799 (and others) in that the new Windows
start & applications keys (keycode 91,92,93) generate KeyEvent KeyCode=0. The
new internet keyboards (pro) with browser keys behave the same way.
I suspect there are many other keyboards (point of sale, etc) that could utilize
additional keycodes, most of which are application-specific & therefor the
KeyCodes are not needed by JVM.
If the jvm does not recognize the keycode, I believe it should leave it as-is,
so an application can then recognize it & act. At a minimum it seems there
should be a properties or mapping or init file that defines the valid keys, but
I haven;t found it.
Sample program below, click in the typing area, press the MS windows or
application key, the keycode is allways 0. other keys work fine. Try with an
internet keyboard if you like, and with MS's jview.
Here's the System.Out info from the keypress:
KeyCode=0 modifiers=0
KeyEvent=java.awt.event.KeyEvent[KEY_PRESSED,keyCode=0,keyChar='?'] on textfield
0
If there's a workaround or something i've missed, i'd appreciate any help.
thanks in advance.
Sample program:
// ==== keyboard test pgogram ===========================================
import java.util.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*; // for KeyStroke
/**
* Title: <p>
* Description: <p>
* Copyright: Copyright (c) <p>
* Company: <p>
* @author
* @version 1.0
*/
public class key1 extends Frame {
Label lbKeyPressed = new Label();
Label lbKeyTyped = new Label();
Label lbKeyReleased = new Label();
Label lbKeyCode = new Label();
Label lbKeyChar = new Label();
TextField txtKpKc = new TextField();
TextField txtKtKc = new TextField();
TextField txtKrKc = new TextField();
TextField txtKpKh = new TextField();
TextField txtKtKh = new TextField();
TextField txtKrKh = new TextField();
TextField txtTyping = new TextField();
Label lbTyping = new Label();
Label lbAbout = new Label();
Label lbAbout1 = new Label();
// public LinkedList properties;
public key1() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
key1 key11 = new key1();
key11.setSize(600,400);
key11.show();
}
private void jbInit() throws Exception {
lbKeyPressed.setBounds(new Rectangle(101, 45, 84, 23));
lbKeyPressed.setFont(new java.awt.Font("Dialog", 1, 12));
lbKeyPressed.setText("Key Pressed");
this.setLayout(null);
lbKeyTyped.setBounds(new Rectangle(245, 45, 81, 18));
lbKeyTyped.setFont(new java.awt.Font("Dialog", 1, 12));
lbKeyTyped.setText("Key Typed");
lbKeyReleased.setBounds(new Rectangle(380, 46, 92, 23));
lbKeyReleased.setFont(new java.awt.Font("Dialog", 1, 12));
lbKeyReleased.setText("Key Released");
lbKeyCode.setBounds(new Rectangle(18, 80, 61, 21));
lbKeyCode.setFont(new java.awt.Font("Dialog", 1, 12));
lbKeyCode.setText("Key Code");
lbKeyChar.setBounds(new Rectangle(18, 122, 61, 23));
lbKeyChar.setFont(new java.awt.Font("Dialog", 1, 12));
lbKeyChar.setText("Key Char");
txtKpKc.setBounds(new Rectangle(100, 83, 105, 25));
txtKtKc.setBounds(new Rectangle(243, 79, 103, 24));
txtKrKc.setBounds(new Rectangle(378, 80, 96, 22));
txtKpKh.setBounds(new Rectangle(99, 119, 108, 23));
txtKtKh.setBounds(new Rectangle(243, 120, 103, 23));
txtKrKh.setBounds(new Rectangle(377, 116, 99, 24));
txtTyping.setBounds(new Rectangle(106, 232, 264, 32));
txtTyping.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(KeyEvent e) {
txtTyping_keyPressed(e);
}
public void keyReleased(KeyEvent e) {
txtTyping_keyReleased(e);
}
public void keyTyped(KeyEvent e) {
txtTyping_keyTyped(e);
}
});
lbTyping.setBounds(new Rectangle(108, 197, 183, 30));
lbTyping.setFont(new java.awt.Font("Dialog", 1, 12));
lbTyping.setText("Typing Area");
lbAbout.setBounds(new Rectangle(51, 342, 398, 26));
lbAbout.setFont(new java.awt.Font("Dialog", 1, 12));
lbAbout.setText("Java Key Tester, Version 1.0");
lbAbout1.setBounds(new Rectangle(46, 364, 281, 29));
lbAbout1.setFont(new java.awt.Font("Dialog", 1, 12));
lbAbout1.setText("Copyright, Corp.");
this.add(txtTyping, null);
this.add(lbTyping, null);
this.add(lbAbout1, null);
this.add(lbAbout, null);
this.add(lbKeyChar, null);
this.add(txtKpKh, null);
this.add(txtKtKh, null);
this.add(txtKrKh, null);
this.add(txtKrKc, null);
this.add(txtKtKc, null);
this.add(lbKeyCode, null);
this.add(txtKpKc, null);
this.add(lbKeyPressed, null);
this.add(lbKeyTyped, null);
this.add(lbKeyReleased, null);
}
void txtTyping_keyPressed(KeyEvent e) {
System.out.println("KeyCode=" + e.getKeyCode()+ " modifiers=" +
e.getModifiers());
System.out.println("KeyEvent=" + e);
txtKpKc.setText("");
txtKpKh.setText("");
txtKrKc.setText("");
txtKrKh.setText("");
txtKtKc.setText("");
txtKtKh.setText("");
txtKpKc.setText(String.valueOf(e.getKeyCode()));
txtKpKh.setText(String.valueOf(e.getKeyChar()));
}
void txtTyping_keyReleased(KeyEvent e) {
txtKrKc.setText(String.valueOf(e.getKeyCode()));
txtKrKh.setText(String.valueOf(e.getKeyChar()));
}
void txtTyping_keyTyped(KeyEvent e) {
txtKtKc.setText(String.valueOf(e.getKeyCode()));
txtKtKh.setText(String.valueOf(e.getKeyChar()));
}
}
(Review ID: 106556)
======================================================================
FULL PRODUCT VERSION :
java version "1.4.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03)
Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode)
FULL OPERATING SYSTEM VERSION :
customer Windows 2000 [Version 5.00.2195]
SP 2
A DESCRIPTION OF THE PROBLEM :
When using newer Internet-enabled keyboards such as the
Mircosoft Internet Pro, or Compaq EasyAccess keyboard,
the internet / extended keys such VK_BROWSER_BACK, _FORWARD,
etc through VK_LAUNCH_APP2 (WIndows VKs, not java Keyevent)
all return keyCode 0 for KeyPressed events getKeyCode()
They should return valid keycodes.
Similar to Bug Id 4352104, but not quite the same.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.connect customer Internet keyboard.
2.run KeyEventDemo
http://java.sun.com/docs/books/tutorial/uiswing/events/KeyEv
entDemo.html
3. press any of the internet keys.
EXPECTED VERSUS ACTUAL BEHAVIOR :
expected: valid keyCodes
actual: key code = 0
ERROR MESSAGES/STACK TRACES THAT OCCUR :
KEY PRESSED:
key character = '?'
key code = 0 (Unknown keyCode: 0x0)
modifiers = 0 (no modifiers)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
http://java.sun.com/docs/books/tutorial/uiswing/events/KeyEventDemo.html
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
Use customer Java.
(Review ID: 159682)
======================================================================
|
|
Comments
|
Submitted On 12-OCT-2000
SKid
Please do NOT do the mistake and name the VK_CONSTANTS for these keys like "VK_APPLE" or
"VK_WINDOWS".
Please define a more abstract way, like "VK_SYSTEM" or something like that, because the intuitive meaning is
that something happens with the system or that more global functions are executed.
The applications key is very important.
It should be called "VK_CONTEXT" or something like that, because it delivers context-dependend functions to the
user.
Bye
Submitted On 18-DEC-2000
SKid
Evaluator, 2000-12-11:
No!! That would make no difference. If native keys are supported only by jawt, I could write a native
solution anyway.
Support from the Java-Side is necessary, because we want to write Java.
You must accept, that you cannot fire-and-forget the key-mappings. The will maybe change in the future
from time to time, so you will have to extend KeyEvent from time to time.
This is the kind of work I expected Java would do for me.
There are other constants, that I never saw on any PC-Keyboard! Why not supporting these things, that
are on about 90% of all Personal Computers!?
I do not understand this hesitation. This is a must, since the last 5 years.
????
Submitted On 09-JAN-2001
pridemor
I just ran head-on into this problem. My team is developing
a point-of-sale application and needs to intercept input
from a specialized keyboard. Most of the keys map to
standard keycodes (but the keys are labelled differently);
however, there are three keys on this IBM keyboard which all
return zero for the keycode. I have to be able to
distinguish between them and would rather not have to write
native code, but I see no alternative at this point...
Submitted On 04-OCT-2001
Hidenobu
One japanese customer who develops Java application for
handicapped members, strongly hopes this request is
supported very shortly.
Their application is educational software used by
handicapped members who are blind naturally.
And so, their application needs to notify such users if
blind users happen
to push any special key like Windows keys or Applications
keys.
Because when blind users push Windows keys or Applications
keys,
the window of Java application goes out of focus and users
never know that.
This is a major feedback about Java Accessibility Option.
Please consider such an important aspect also.
Submitted On 05-APR-2002
cpell
I actually was under the impression that a KeyEvent.VK_MENU
field already existed, until I found myself needing to catch
the key and went looking for it in the javadoc. I know I've
seen a number of X terminals with a "Menu" key, and
considering the presence of an XK_Menu in X11/keysymdef.h, I
gather I'm not the only one.
I'm not as certain about the Windws Start Menu key. Other
than games, how many applications detect this key, or need
to detect it? As for games... they would need to actually
block it (perhaps at the user's option), which is another
issue entirely.
Submitted On 19-JUL-2002
roadkill_55
The new browser keys on internet keyboards such as the
WebHome, refresh keys, also return keycode = 0.
(Win 2000 & Java 1.4)
Submitted On 04-APR-2003
murkles
Surely given the fact that there are such a diverse number of
keyboards and applications that should be able to utilise non-
standard keys there should be a standard api to give an
application access to them. It seems to me that if you take
the current approach you are never going to keep everyone
happy and will rather always be one step behind requirements.
Submitted On 25-APR-2004
Fuerte3
This bug means that NetBeans 3.6 IDE is almost unusable. It
is not possible to match brace with Ctrl+[ because [
requires AltGr+8 in Finnish keyboard. We have the letter Å
in place of [, but it is not possible to add a keyboard
shortcut for Ctrl+Å because this key is Unknown.
Also the key § (above Tab, left to 1) where US English have
` is Unknown, so switching between windows with Ctrl+§ is
not possible.
I think that the suggestion to leave the original keycode
from Win32 is correct. These are the keys in Finnish
keyboard that Java 1.4 does not support:
ÅÄÖ§
Submitted On 28-APR-2004
Fuerte3
More info: In Win32 I get KEY PRESSED (keycode=0), KEY TYPED
and KEY RELEASED (keycode=0) for these Finnish keys. I Linux
I get only KEY TYPED and KEY RELEASED.
Here are the Finnish key codes:
Key Keycode
§ 220 0xDC
Å 221 0xDD
Ä 222 0xDE
Ö 192 0xCO
Here is a utility to view national keyboards (IE only):
http://www.microsoft.com/globaldev/reference/keyboards.aspx
Here is a list of virtual key codes. The Finnish keys above
are VK_OEM_4 etc.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/w98ddk/hh/w98ddk/keycnt_4fqr.asp
Submitted On 28-APR-2004
Fuerte3
VK_F1 70h
VK_F2 71h
VK_F3 72h
VK_F4 73h
VK_F5 74h
VK_F6 75h
VK_F7 76h
VK_F8 77h
VK_F9 78h
VK_F10 79h
VK_F11 7Ah
VK_F12 7Bh
VK_F13 7Ch
VK_F14 7Dh
VK_F15 7Eh
VK_F16 7Fh
VK_F17 80h
VK_F18 81h
VK_F19 82h
VK_F20 83h
VK_F21 84h
VK_F22 85h
VK_F23 86h
VK_F24 87h
88h through 8Fh unassigned.
VK_NUMLOCK 090h NUMLOCK on all keyboards.
VK_OEM_SCROLL 091h SCROLL LOCK on all keyboards.
92h through B9h unassigned.
VK_OEM_1 0BAh Punctuation.
VK_OEM_PLUS 0BBh Punctuation.
VK_OEM_COMMA 0BCh Punctuation.
VK_OEM_MINUS 0BDh Punctuation.
VK_OEM_PERIOD 0BEh Punctuation.
VK_OEM_2 0BFh Punctuation.
VK_OEM_3 0C0h Punctuation.
C1h through DAh unassigned.
VK_OEM_4 0DBh Punctuation.
VK_OEM_5 0DCh Punctuation.
VK_OEM_6 0DDh Punctuation.
VK_OEM_7 0DEh Punctuation.
VK_OEM_8 0DFh Punctuation.
VK_F17 0E0h F17 key on Olivetti extended keyboard
(internal use only).
VK_F18 0E1h F18 key on Olivetti extended keyboard
(internal use only).
VK_OEM_102 0E2h < or | on IBM-compatible 102 enhanced
keyboard (non-U.S.).
VK_ICO_HELP 0E3h Help key on Olivetti extended keyboard
(internal use only).
VK_ICO_00 0E4h 00 key on Olivetti extended keyboard
(internal use only).
E5h unassigned.
VK_ICO_CLEAR 0E6h Olivetti extended keyboard (internal use
only).
E7h and E8h unassigned.
VK_OEM_RESET 0E9H Only used by Nokia.
VK_OEM_JUMP 0EAH Only used by Nokia.
VK_OEM_PA1 0EBH Only used by Nokia.
VK_OEM_PA2 0ECH Only used by Nokia.
VK_OEM_PA3 0EDH Only used by Nokia.
VK_OEM_WSCTRL 0EEH Only used by Nokia.
VK_OEM_CUSEL 0EFH Only used by Nokia.
VK_OEM_ATTN 0F0H Only used by Nokia.
VK_OEM_FINNISH 0F1H Only used by Nokia.
VK_OEM_COPY 0F2H Only used by Nokia.
VK_OEM_AUTO 0F3H Only used by Nokia.
VK_OEM_ENLW 0F4h Only used by Nokia.
VK_OEM_BACKTAB 0F5h Only used by Nokia.
VK_ATTN 0F6H
VK_CRSEL 0F7H
VK_EXSEL 0F8H
VK_EREOF 0F9H
VK_PLAY 0FAH
VK_ZOOM 0FBH
VK_NONAME 0FCH
VK_PA1 0FDH
VK_OEM_CLEAR 0FEH
Submitted On 28-APR-2004
Fuerte3
Virtual-Key Code Definitions
The following table includes the virtual-key codes that are
defined for Windows. The key code values 0 and 0FFh are not
used.
Name Value Comment
VK_LBUTTON 01h Left mouse button.
VK_RBUTTON 02h Right mouse button.
VK_CANCEL 03h Used for control-break processing.
VK_MBUTTON 04h Middle mouse button (3-button mouse).
05h through 07h undefined.
VK_BACK 08h
VK_TAB 09h
0Ah and 0Bh undefined.
VK_CLEAR 0Ch
VK_RETURN 0Dh
0Eh and 0Fh undefined.
VK_SHIFT 10h
VK_CONTROL 11h
VK_MENU 12h
VK_PAUSE 13h
VK_CAPITAL 14h
15h through 1Ah undefined.
VK_ESCAPE 1Bh
1Ch through 1Fh undefined.
VK_SPACE 20h
VK_PRIOR 21h Page up.
VK_NEXT 22h Page down.
VK_END 23h
VK_HOME 24h
VK_LEFT 25h
VK_UP 26h
VK_RIGHT 27h
VK_DOWN 28h
VK_SELECT 29h
VK_PRINT 2Ah Only used by Nokia.
VK_EXECUTE 2Bh Never used.
VK_SNAPSHOT 2Ch SYSREQ key starting with Windows 3.0.
VK_INSERT 2Dh
VK_DELETE 2Eh
VK_HELP 2Fh
VK_0 30h
VK_1 31h
VK_2 32h
VK_3 33h
VK_4 34h
VK_5 35h
VK_6 36h
VK_7 37h
VK_8 38h
VK_9 39h
3Ah though 40h undefined.
VK_A 41h
VK_B 42h
VK_C 43h
VK_D 44h
VK_E 45h
VK_F 46h
VK_G 47h
VK_H 48h
VK_I 49h
VK_J 4Ah
VK_K 4Bh
VK_L 4Ch
VK_M 4Dh
VK_N 4Eh
VK_O 4Fh
VK_P 50h
VK_Q 51h
VK_R 52h
VK_S 53h
VK_T 54h
VK_U 55h
VK_V 56h
VK_W 57h
VK_X 58h
VK_Y 59h
VK_Z 5Ah
5Bh through 5Fh undefined.
VK_NUMPAD0 60h
VK_NUMPAD1 61h
VK_NUMPAD2 62h
VK_NUMPAD3 63h
VK_NUMPAD4 64h
VK_NUMPAD5 65h
VK_NUMPAD6 66h
VK_NUMPAD7 67h
VK_NUMPAD8 68h
VK_NUMPAD9 69h
VK_MULTIPLY 6Ah
VK_ADD 6Bh
VK_SEPARATER 6Ch Never generated by keyboard driver.
VK_SUBTRACT 6Dh
VK_DECIMAL 6Eh
VK_DIVIDE 6Fh
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|