-
Bug
-
Resolution: Fixed
-
P3
-
1.3.0
-
beta
-
x86
-
linux
Name: yyT116575 Date: 11/20/2000
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
Java HotSpot(TM) Client VM (build 1.3.0, mixed mode)
Here is the source of the demo i use to demonstrate the problem :
import java.awt.*;
import java.awt.event.*;
public class TestKey extends Frame {
public TestKey() {
super();
setSize(200, 200);
addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
System.out.println("pressed " + e.getKeyText(e.getKeyCode()));
}
public void keyReleased(KeyEvent e) {
System.out.println("released " + e.getKeyText(e.getKeyCode()));
}
});
}
public static void main(String[] s) {
TestKey t = new TestKey();
t.setVisible(true);
}
}
Run the demo.
If you press the "a" key, the demo will print :
pressed A
released A
pressed A
released A
pressed A
released A
...
This is logic if we consider that all pressed event should have a corresponding
release event.
But if you press "a", then "z", then you release "z" and then "a", you have :
pressed A
released A
pressed A
released A
pressed A
pressed Z
released Z
pressed Z
released Z
There is no release event for the last "presses A" ! And there is no way in java
to know when the "a" key is released...
This problem occurs at least under Linux and Windows, and it is very paintfull
for apps like game...
(Review ID: 112547)
======================================================================