-
Bug
-
Resolution: Fixed
-
P3
-
18, 19, 20, 21
-
Reproducible only on MacOS (currently it is 13.5.1)
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8343255 | 21.0.6 | Goetz Lindenmaier | P3 | Resolved | Fixed | b02 |
Starting from JDK18 KeyEvents started to have different keycode on different keyboard layouts.
Because of that shortcuts (like copy/paste) stopped to work on non-english locales.
Everything works fine in JDKs 17 and older.
It seems like this is the regression produced by this commit: https://github.com/openjdk/jdk/commit/47e7a42594f1c36f71cdf4d383080bf8d616b7e7
With this code
```
import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
public class Example {
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
var frame = new JFrame();
frame.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
System.out.println("CODE " + KeyEvent.VK_C + " REAL CODE " + e.getKeyCode());
}
@Override
public void keyReleased(KeyEvent e) {
}
});
frame.setSize(new Dimension(200, 200));
frame.setVisible(true);
});
}
}
```
Steps to reproduce:
1. Run the application
2. Change locale to English
3. Press cmd + C
4. Change locale to Russian (may be on other it will also fail)
5. Press cmd + C
Expected:
CODE 67 REAL CODE 67
printed on both locales
Actual -
CODE 67 REAL CODE 67
is printed on English locale
CODE 67 REAL CODE 16778305
is printed on Russian locale
Because of that shortcuts (like copy/paste) stopped to work on non-english locales.
Everything works fine in JDKs 17 and older.
It seems like this is the regression produced by this commit: https://github.com/openjdk/jdk/commit/47e7a42594f1c36f71cdf4d383080bf8d616b7e7
With this code
```
import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
public class Example {
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
var frame = new JFrame();
frame.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
System.out.println("CODE " + KeyEvent.VK_C + " REAL CODE " + e.getKeyCode());
}
@Override
public void keyReleased(KeyEvent e) {
}
});
frame.setSize(new Dimension(200, 200));
frame.setVisible(true);
});
}
}
```
Steps to reproduce:
1. Run the application
2. Change locale to English
3. Press cmd + C
4. Change locale to Russian (may be on other it will also fail)
5. Press cmd + C
Expected:
CODE 67 REAL CODE 67
printed on both locales
Actual -
CODE 67 REAL CODE 67
is printed on English locale
CODE 67 REAL CODE 16778305
is printed on Russian locale
- backported by
-
JDK-8343255 [macos] Regression: KeyEvent has different keycode on different keyboard layouts
- Resolved
- relates to
-
JDK-8321042 Test java/awt/event/KeyEvent/AcceleratorTest/AcceleratorTest.java fails on macOS
- Open
-
JDK-8262945 [macos] Regression Manual Test for Key Events Fails
- Resolved
- links to
-
Commit openjdk/jdk/a3eb6640
-
Commit(master) openjdk/jdk21u-dev/bcd09582
-
Review openjdk/jdk/16664
-
Review(master) openjdk/jdk21u-dev/1104
(2 links to)