JDK-4203982 : Keypad key codes are not unique
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.1.8,1.2.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,windows_nt
  • CPU: generic,x86
  • Submitted: 1999-01-19
  • Updated: 2001-04-14
  • Resolved: 2001-04-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.0 betaFixed
Related Reports
Relates :  
Description

Name: krT82822			Date: 01/19/99


A unique key code is not reported for the keypads ENTER, LF, RT, UP, 
DN, INS, DEL, HOME, END, PAGE UP, and PAGE DN keystrokes.  The 
keycode is the same as reported for the matching keys. The 
keycode is also the same for the left and right shift, and the 
left and right ctrl key.(The ENTER is high priority to me.)  

I wrote a sample C++ program.  Although the virtual key code 
was the same the scan code was different between the main enter 
key and the keypad enter key.

Although I have only tested using Windows NT I am told it also
occurs on a SUN box.

To reproduce, implement the following KeyListener methods.  


   /** Handle the key typed event from the text field. */
    public void keyTyped(KeyEvent e) {
        displayInfo(e, "KEY TYPED: ");
    }

    /** Handle the key pressed event from the text field. */
    public void keyPressed(KeyEvent e) {
       displayInfo(e, "KEY PRESSED: ");
    }

    /** Handle the key released event from the text field. */
    public void keyReleased(KeyEvent e) {
        displayInfo(e, "KEY RELEASED: ");
    }
    
    protected void displayInfo(KeyEvent e, String s){
        String charString, keyCodeString, modString, tmpString;

        char c = e.getKeyChar();
        int keyCode = e.getKeyCode();
        int modifiers = e.getModifiers();

        if (Character.isISOControl(c)) {
            charString = "key character = (an unprintable control character)";
        } else {
            charString = "key character = '" + c + "'";
        }

        keyCodeString = "key code = " + keyCode+ 
                        " ("+ KeyEvent.getKeyText(keyCode)+ ")";

        modString = "modifiers = " + modifiers;
        tmpString = KeyEvent.getKeyModifiersText(modifiers);
        if (tmpString.length() > 0) {
            modString += " (" + tmpString + ")";
        } else {
            modString += " (no modifiers)";
        }

        System.out.println(s+"    "+ charString);
        System.out.println("    "+ keyCodeString);
        System.out.println("    "+ modString);
    }

You will notice the output when pressing the normal enter key 
and the keypad enter key both produce the same output:

KEY PRESSED:     key character = (an unprintable control character)
    key code = 10 (Enter)
    modifiers = 0 (no modifiers)
KEY TYPED:     key character = (an unprintable control character)
    key code = 0 (Unknown keyCode: 0x0)
    modifiers = 0 (no modifiers)
KEY RELEASED:     key character = (an unprintable control character)
    key code = 10 (Enter)
    modifiers = 0 (no modifiers)
(Review ID: 52427)
======================================================================

Name: krT82822			Date: 12/03/99


Not relevant

We would like some way of differentiating between the Enter key on the numeric
keypad and the standard Enter key on the main key board.  At the moment
both register as the same virtual key.
(Review ID: 98605)
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: merlin-beta FIXED IN: merlin-beta INTEGRATED IN: merlin-beta
14-06-2004

EVALUATION Since addressing this problem requires API changes (new keycodes) I have reclassified it as an RFE. See also 4069679, 4072265, 4106941, 4087898. eric.hawkes@eng 1999-01-19 This bug was fixed by the work done for 4424517 in merlin. eric.hawkes@eng 2001-04-13
19-01-1999