Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4106941

KeyCodes for numeric keypad arrow keys are inconsistent between win32/Solaris

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 1.2.0
    • client-libs
    • sparc
    • solaris_2.6

      KeyCodes for the arrow keys on the numeric keypad are different between Win32 and Solaris. They used to be identical in 1.1.6 (37, 38, 39, 40, but in 1.2 they have changed on Solaris (226, 224, 227, 225) and not changed on Win32.

      Run the following applet on Solaris, click in the TextArea, and hit the arrow keys on the numeric keypad, with NumLock OFF. It will print the following KeyCodes:
          KeyChar= KeyCode=226 KeyText=Left
          KeyChar= KeyCode=224 KeyText=Up
          KeyChar= KeyCode=227 KeyText=Right
          KeyChar= KeyCode=225 KeyText=Down

      Then run the applet on Win32, click in the TextArea, and hit the same arrow keys. It will print the following KeyCodes:
          KeyChar= KeyCode=37 KeyText=Left
          KeyChar= KeyCode=38 KeyText=Up
          KeyChar= KeyCode=39 KeyText=Right
          KeyChar= KeyCode=40 KeyText=Down


      //-------------------ArrowKey2.html--------------------------
      <html>
      <body>
      <applet code=ArrowKey2.class width=400 height=150></applet>
      </body>
      </html>


      //-------------------ArrowKey2.java--------------------------
      import java.applet.*;
      import java.awt.*;
      import java.awt.event.*;

      public class ArrowKey2 extends Applet
      {
          private KeyWatch keyear;
          private TextArea fld;

          public ArrowKey2() {}

          public void init()
          {
              keyear = new KeyWatch();
              this.setLayout(new FlowLayout(FlowLayout.CENTER, 30, 30));
              fld = new TextArea("Some Text\nSome Text\nSome Text\nSome Text",
                          10, 20);
              this.add(fld);
              fld.addKeyListener(keyear);
              this.addKeyListener(keyear);
          }
      }

      class KeyWatch extends KeyAdapter
      {
          public void keyPressed(KeyEvent e)
          {
              System.out.print("KeyChar=" + e.getKeyChar());
              System.out.print(" KeyCode=" + e.getKeyCode() );
              System.out.println(" KeyText=" + e.getKeyText(e.getKeyCode()));
          }
      }

            ehawkessunw Eric Hawkes (Inactive)
            bklocksunw Brian Klock (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: