-
Bug
-
Resolution: Fixed
-
P3
-
8
-
b23
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8188633 | 8u172 | Dmitry Markov | P3 | Resolved | Fixed | b01 |
JDK-8190635 | 8u171 | Dmitry Markov | P3 | Resolved | Fixed | b01 |
JDK-8198129 | emb-8u171 | Dmitry Markov | P3 | Resolved | Fixed | b01 |
Full JDK Versions
-----------------
Reproducible since 7u4 (first Mac release)
System Configuration
--------------------
Mac OS
Problem Description
-------------------
Under certain circumstances, some key press events seem to be lost on
Mac OS with Java 8.
The testcase provided contains a JFrame with a with a KeyListener attached.
The listener prints a line describing keyPressed, keyReleased and keyTyped
events. If the user presses and holds a key, you will see a KEY_PRESSED
event, followed by a KEY_TYPED event, and then nothing*. Once the key is
released, a KEY_RELEASED event is seen, as expected, but from that point
onwards any further key presses only generate KEY_RELEASED events. The
expected KEY_PRESSED and KEY_TYPED events do not appear.
The problem only seems to occur with keys which correspond to letters which
have alternative accented forms. For example, the problem occurs with 'a',
'e', and 'i', but not with 'f'.
This issue is reproducible on all Mac releases, from 7u4 (the first Mac
release) onwards.
* This may also be a bug. The behavior differs from other platforms such as
Windows, where rapidly repeating KEY_PRESSED and KEY_TYPED events are seen
when keys are held down.
Testcase
--------
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JFrame;
import java.util.Date;
public class TestProject {
public static void main(String[] args) {
JFrame mainFrame = new JFrame("TestProject");
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainFrame.addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent event) {
System.out.println(new Date() + " Key Pressed: " + event);
}
public void keyReleased(KeyEvent event) {
System.out.println(new Date() + " Key Released: " + event);
}
public void keyTyped(KeyEvent event) {
System.out.println(new Date() + " Key Typed: " + event);
}
});
mainFrame.pack();
mainFrame.setSize(640, 480);
mainFrame.setVisible(true);
while(true) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {}
}
}
}
Reproduction Instructions
-------------------------
1. Compile and run the testcase provided
2. Press and release the 'i' key once, quickly, which correctly shows the
KEY_PRESSED, KEY_TYPED and KEY_RELEASED events being printed, as expected.
3. Press and hold the 'i' key for 3 seconds, and release.
4. Press and release the 'i' key repeatedly. Each time, note that only the
KEY_RELEASED event is seen. The KEY_PRESSED and KEY_TYPED events are missing.
Observed output for steps 3 and 4:
Thu Feb 23 15:50:54 IST 2017 Key Pressed:
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=73,keyText=I,keyChar='i',keyLocati
on=KEY_LOCATION_STANDARD,rawCode=0,primaryLevelUnicode=0,scancode=0,extendedKe
yCode=0x49] on frame0
Thu Feb 23 15:50:54 IST 2017 Key Typed:
java.awt.event.KeyEvent[KEY_TYPED,keyCode=0,keyText=Unknown keyCode:
0x0,keyChar='i',keyLocation=KEY_LOCATION_UNKNOWN,rawCode=0,primaryLevelUnicode
=0,scancode=0,extendedKeyCode=0x49] on frame0
Thu Feb 23 15:50:57 IST 2017 Key Released:
java.awt.event.KeyEvent[KEY_RELEASED,keyCode=73,keyText=I,keyChar='i',keyLocat
ion=KEY_LOCATION_STANDARD,rawCode=0,primaryLevelUnicode=0,scancode=0,extendedK
eyCode=0x49] on frame0
Thu Feb 23 15:51:03 IST 2017 Key Released:
java.awt.event.KeyEvent[KEY_RELEASED,keyCode=73,keyText=I,keyChar='i',keyLocat
ion=KEY_LOCATION_STANDARD,rawCode=0,primaryLevelUnicode=0,scancode=0,extendedK
eyCode=0x49] on frame0
Thu Feb 23 15:51:05 IST 2017 Key Released:
java.awt.event.KeyEvent[KEY_RELEASED,keyCode=73,keyText=I,keyChar='i',keyLocat
ion=KEY_LOCATION_STANDARD,rawCode=0,primaryLevelUnicode=0,scancode=0,extendedK
eyCode=0x49] on frame0
- backported by
-
JDK-8188633 Missing key events on Mac Os
-
- Resolved
-
-
JDK-8190635 Missing key events on Mac Os
-
- Resolved
-
-
JDK-8198129 Missing key events on Mac Os
-
- Resolved
-