ADDITIONAL SYSTEM INFORMATION :
Mac OS Big Sur/ Java Open JDK 17
A DESCRIPTION OF THE PROBLEM :
Our application has an action triggered using the Control-Space keyboard shortcut on Mac OS. Unfortunately with newer Java versions like 17, triggering the shortcut no longer calls the action.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the code below which adds a key listener on a JTextArea and list all key pressed events, the Ctrl-Space shortcut does not trigger a specific event. With Java 8 this event is received:
KP java.awt.event.KeyEvent[KEY_PRESSED,keyCode=32,keyText=␣,keyChar='',modifiers=⌃,extModifiers=⌃,keyLocation=KEY_LOCATION_STANDARD,rawCode=0,primaryLevelUnicode=0,scancode=0,extendedKeyCode=0x0]
but with Java 17 the key pressed event containing the space key and the ctrl modifier is no longer received.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The Ctrl-Space keys combination should trigger a key pressed event in the key listener.
ACTUAL -
The Ctrl-Space keys combination does not trigger a key pressed event in the key listener.
---------- BEGIN SOURCE ----------
public static void main(String[] args) {
JFrame fr = new JFrame();
fr.setSize(500, 500);
JTextArea jta = new JTextArea();
jta.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
System.err.println("KT " + e);
}
@Override
public void keyReleased(KeyEvent e) {
System.err.println("KR " + e);
}
@Override
public void keyPressed(KeyEvent e) {
System.err.println("KP " + e);
}
});
fr.getContentPane().add(jta);
fr.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None that I know of.
FREQUENCY : always