JDK-8276786 : Ctrl+Space shortcut key can no longer be mapped to a key stroke
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 17
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: os_x
  • CPU: x86_64
  • Submitted: 2021-10-21
  • Updated: 2021-11-08
  • Resolved: 2021-11-08
Related Reports
Duplicate :  
Description
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



Comments
Additional Information from submitter: =========================== This is a duplicate of JDK-8272602 fixed in Java 17.0.1
08-11-2021

Issue is not reproduced. The Ctrl-Space keys combination triggers key pressed event in the key listener. OS: Mac OS BigSur 11.6 JDK 17 : Pass JDK 18ea : Pass Output: KP java.awt.event.KeyEvent[KEY_PRESSED,keyCode=32,keyText=␣,keyChar=' ',modifiers=⌃,extModifiers=⌃,keyLocation=KEY_LOCATION_STANDARD,rawCode=0,primaryLevelUnicode=0,scancode=0,extendedKeyCode=0x20] Moving it for further evaluation.
07-11-2021