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

KeyEvent KEY_PRESSED not produced when CAPS lock is enabled

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_nt

      Description

      This bug is related to bug 4326296 submitted for Solaris platform.
      Problems identified with this bug are:
      1. During a KEY_PRESSED Event, the keyCode=0 when the Caps Lock is set.
      2. During KEY_TYPED Events, the modifiers section is not being set.

      Code sample:
      import java.awt.*;
      import java.awt.event.*;

      public class Test_Event extends Frame implements KeyListener{

        Test_Event() {
              super("Test_Event");
              setSize(250, 100);
              show();
              this.addKeyListener(this);
        }

        public static void main(String[] args) {
              Frame f = new Test_Event();
        }

        public void keyPressed(KeyEvent ke) {
              printEvent(ke);
        }

        public void keyReleased(KeyEvent ke) {
              printEvent(ke);
        }

        public void keyTyped(KeyEvent ke) {
              printEvent(ke);
        }

        private void printEvent(KeyEvent e) {
              System.out.println("KeyEvent = " + e);
        }
      }


      Output that demonstrates the problem:
      C:\WINDOWS\Desktop>java Test_Event
      KeyEvent = java.awt.event.KeyEvent[KEY_PRESSED,keyCode=18,keyChar='?',modifiers=Alt] on frame0
      KeyEvent = java.awt.event.KeyEvent[KEY_PRESSED,keyCode=65,keyChar='a',modifiers=Alt] on frame0
      KeyEvent = java.awt.event.KeyEvent[KEY_TYPED,keyCode=0,keyChar='a',modifiers=Alt] on frame0
      KeyEvent = java.awt.event.KeyEvent[KEY_RELEASED,keyCode=18,keyChar='?'] on frame0
      KeyEvent = java.awt.event.KeyEvent[KEY_RELEASED,keyCode=65,keyChar='a'] on frame0


      KeyEvent = java.awt.event.KeyEvent[KEY_PRESSED,keyCode=20,Caps Lock] on frame0
      KeyEvent = java.awt.event.KeyEvent[KEY_RELEASED,keyCode=20,Caps Lock] on frame0


      KeyEvent = java.awt.event.KeyEvent[KEY_PRESSED,keyCode=18,keyChar='?',modifiers=Alt] on frame0
      KeyEvent = java.awt.event.KeyEvent[KEY_PRESSED,keyCode=65,keyChar='A',modifiers=Alt] on frame0
      KeyEvent = java.awt.event.KeyEvent[KEY_TYPED,keyCode=0,keyChar='A',modifiers=Alt] on frame0
      KeyEvent = java.awt.event.KeyEvent[KEY_RELEASED,keyCode=18,keyChar='?'] on frame0
      KeyEvent = java.awt.event.KeyEvent[KEY_RELEASED,keyCode=65,keyChar='A'] on frame0


      C:\WINDOWS\Desktop>


        Attachments

          Activity

            People

            • Assignee:
              ehawkessunw Eric Hawkes (Inactive)
              Reporter:
              duke J. Duke (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: