Duplicate :
|
|
Duplicate :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
Name: jk109818 Date: 07/11/2000 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) ====================================================================== Name: gm110360 Date: 09/23/2002 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 : Microsoft 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 Microsoft 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 Microsoft Java. (Review ID: 159682) ======================================================================
|