Details
-
Bug
-
Resolution: Fixed
-
P2
-
8, 9, 10, 11, 12, 13
-
b21
-
Not verified
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8325844 | 11.0.24-oracle | Dmitry Markov | P2 | Closed | Fixed | b01 |
JDK-8329972 | 11.0.24 | Amos SHI | P2 | Resolved | Fixed | b01 |
Description
Seeing some inconsistent behaviour with KeyEvent.getModifiers() for right and left ALT keys in JDK > 1.8
/**
*
* Steps : Run this file using JDK 1.8, Windows, Mac OSX,
* Invoke Left-ALT key, note keyEvent.getModifiers() is 8(InputEvent.ALT_MASK)
* Invoke right-ALT key, getModifiers() returns 8.
*
* Run using JDK 11, Windows
* Invoke Left-ALT key, note keyEvent.getModifiers() is 8
* Invoke right-ALT key, getModifiers() returns 40.
* Switching between left and right alt keys returns same result.
*
* Run using JDK 11, Mac
* Invoke Left-ALT key, note keyEvent.getModifiers() is 8
* Invoke right-ALT key, getModifiers() returns 40(InputEvent.ALT_MASK | InputEvent.ALT_GRAPH_MASK).
* Now again press left alt key,it now starts returning getModifiers as 40, getModifiersEx also returns different value.
*
* Issues/Questions:
* KeyEvent.getModifiers() for ALT keys has changed after JDK 1.8. Is this expected behaviour?
* Is getModifiers() expected to be different for Left ALT key and Rt ALT keys on Windows?
* Is getModifiers, getModifersEx expected to return diff values on Mac and Windows?
* In Mac, left alt key getModifiers, getModifiersEx changing after rt alt key is selected, on JDK 11, looks to be a bug.
*/
public class JavaApplication1 {
public static void main(String[] args) {
JTextField comp = new JTextField();
comp.addKeyListener(new MyListener());
JFrame f = new JFrame();
f.add(comp);
f.setSize(100,100);
f.setVisible(true);
}
}
class MyListener implements KeyListener {
public MyListener() {
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
System.out.println("ModEx : " +e.getModifiersEx());
System.out.println("Mod : " +e.getModifiers());
System.out.println("-----------");
}
@Override
public void keyReleased(KeyEvent e) {
}
}
/**
*
* Steps : Run this file using JDK 1.8, Windows, Mac OSX,
* Invoke Left-ALT key, note keyEvent.getModifiers() is 8(InputEvent.ALT_MASK)
* Invoke right-ALT key, getModifiers() returns 8.
*
* Run using JDK 11, Windows
* Invoke Left-ALT key, note keyEvent.getModifiers() is 8
* Invoke right-ALT key, getModifiers() returns 40.
* Switching between left and right alt keys returns same result.
*
* Run using JDK 11, Mac
* Invoke Left-ALT key, note keyEvent.getModifiers() is 8
* Invoke right-ALT key, getModifiers() returns 40(InputEvent.ALT_MASK | InputEvent.ALT_GRAPH_MASK).
* Now again press left alt key,it now starts returning getModifiers as 40, getModifiersEx also returns different value.
*
* Issues/Questions:
* KeyEvent.getModifiers() for ALT keys has changed after JDK 1.8. Is this expected behaviour?
* Is getModifiers() expected to be different for Left ALT key and Rt ALT keys on Windows?
* Is getModifiers, getModifersEx expected to return diff values on Mac and Windows?
* In Mac, left alt key getModifiers, getModifiersEx changing after rt alt key is selected, on JDK 11, looks to be a bug.
*/
public class JavaApplication1 {
public static void main(String[] args) {
JTextField comp = new JTextField();
comp.addKeyListener(new MyListener());
JFrame f = new JFrame();
f.add(comp);
f.setSize(100,100);
f.setVisible(true);
}
}
class MyListener implements KeyListener {
public MyListener() {
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
System.out.println("ModEx : " +e.getModifiersEx());
System.out.println("Mod : " +e.getModifiers());
System.out.println("-----------");
}
@Override
public void keyReleased(KeyEvent e) {
}
}
Attachments
Issue Links
- backported by
-
JDK-8329972 KeyEvent.getModifiers() returns inconsistent values for ALT keys
- Resolved
-
JDK-8325844 KeyEvent.getModifiers() returns inconsistent values for ALT keys
- Closed
- relates to
-
JDK-8222279 [macos] Behavior selection for ALTGR on Mac
- Open