JDK-8020209 : [macosx] Mac OS X key event confusion for " COMMAND PLUS "
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 7u6
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: os_x
  • Submitted: 2013-07-01
  • Updated: 2014-03-11
  • Resolved: 2013-10-22
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8 b115Fixed
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
1.7.0_25-b15 or 1.8.0-ea-b91 (should be uniform for any JDK 7 or 8)

ADDITIONAL OS VERSION INFORMATION :
Mac OS X 8.x (Snow Leopard)

A DESCRIPTION OF THE PROBLEM :
This is a Mac OS X specific problem for JDK 7 and JDK 8 (early access).

COMMAND PLUS produces 3 (equal) events KEY PRESSED instead of just 1.
In contrast, COMMAND MINUS works as expected.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Use KeyEventDemo.java from http://docs.oracle.com/javase/tutorial/uiswing/events/keylistener.html

Press COMMAND PLUS, i.e. the regular key labelled  " + = "  on an English keyboard.


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
KEY PRESSED:
    key code = 61 (Equals)
    extended modifiers = 256 (Meta)
    action key? NO
    key location: standard

ACTUAL -

KEY PRESSED
    key code = 61 (Equals)
    extended modifiers = 256 (Meta)
    action key? NO
    key location: standard
KEY PRESSED:
    key code = 61 (Equals)
    extended modifiers = 256 (Meta)
    action key? NO
    key location: standard
KEY PRESSED:
    key code = 61 (Equals)
    extended modifiers = 256 (Meta)
    action key? NO
    key location: standard

That is: 3 events instead of just 1.

Note that on JDK 6 from Apple, there are slightly different events KEY PRESSED, KEY TYPED, KEY RELEASED, but that is a different story.

On JDK 7 and 8-ea, COMMAND MINUS produces just one KEY PRESSED event as expected.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
http://docs.oracle.com/javase/tutorial/uiswing/examples/events/KeyEventDemoProject/src/events/KeyEventDemo.java
---------- END SOURCE ----------
Comments
java/awt/event/KeyEvent/8020209/bug8020209.java PASSED under JDK 8 b132 on MacOS, Linux, Solaris, Windows. Closed issue as Fixed/Verified.
11-03-2014

A regression test test/java/awt/event/KeyEvent/8020209/bug8020209.java has been added.
22-10-2013

we have enough stabilization time frame in jdk8 for risky fix (make it around nearest days) by properly reviewed fix as usual
29-08-2013

So, SQE comment is about "Cmd ." key stroke. I've looked at it and it's another manifestation of the same problem as with "Cmd +". After some research, I've found a way to fix both problems, but the fix would be a risky one and somewhat controversial (I'll have to convince reviewers that the fix is the only way to go). So, considering all that, I'm not sure should I address this bug now or postpone it after JDK 8 release.
29-08-2013

Leonid, please evaluate this sentence from SQE: "In this one, three (instead of one) KEY_PRESSED events are subtly different, that may be a manifest of some more serious underlying bug." If that is not the case, please set up 8-client-defer-candidate label again
26-08-2013

While the cause of the issue is clear - it happens because Cocoa call performKeyEquivalent twice for "Cmd +" - I've no clear solution for it at the moment. Not sure I'll be able to fix it before JDK 8 release.
26-08-2013

The issue with Command + . is different from Command + Plus. I've investigated the latter, and the triple key press comes from OS X, so we have to work around it somehow. But I don't think it's P2: what we have there is not a bug in our code that affects every key press, but some special case that we don't handle properly.
22-08-2013

In this one, three (instead of one) KEY_PRESSED events are subtly different, that may be a manifest of some more serious underlying bug.
13-08-2013

Also, try Command + . (press Cmd then period on regular keyboard). You will see the events: KEY_PRESSED; jcode:0x9d; keytext:Meta; keychar:<U+FFFF> (ffff);modifrs:Meta (4); loc:LEFT; paramString:KEY_PRESSED,keyCode=157,keyText=Meta,keyChar=Undefined keyChar,modifiers=Meta,extModifiers=Meta,keyLocation=KEY_LOCATION_LEFT,rawCode=0,primaryLevelUnicode=0,scancode=0,extendedKeyCode=0x0 KEY_PRESSED; jcode:0x2e; keytext:Period; keychar:. (2e);modifrs:Meta (4); loc:STANDARD; paramString:KEY_PRESSED,keyCode=46,keyText=Period,keyChar='.',modifiers=Meta,extModifiers=Meta,keyLocation=KEY_LOCATION_STANDARD,rawCode=0,primaryLevelUnicode=0,scancode=0,extendedKeyCode=0x0 KEY_PRESSED; jcode:0x41; keytext:A; keychar:(1b);modifrs: (0); loc:STANDARD; paramString:KEY_PRESSED,keyCode=65,keyText=A,keyChar=Escape,keyLocation=KEY_LOCATION_STANDARD,rawCode=0,primaryLevelUnicode=0,scancode=0,extendedKeyCode=0x0 KEY_TYPED; jcode:0x0; keytext:Unknown keyCode: 0x0; keychar:(1b);modifrs: (0); loc:UNKNOWN; paramString:KEY_TYPED,keyCode=0,keyText=Unknown keyCode: 0x0,keyChar=Escape,keyLocation=KEY_LOCATION_UNKNOWN,rawCode=0,primaryLevelUnicode=0,scancode=0,extendedKeyCode=0x0 KEY_RELEASED; jcode:0x9d; keytext:Meta; keychar:<U+FFFF> (ffff);modifrs: (0); loc:LEFT; paramString:KEY_RELEASED,keyCode=157,keyText=Meta,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_LEFT,rawCode=0,primaryLevelUnicode=0,scancode=0,extendedKeyCode=0x0 KEY_RELEASED; jcode:0x2e; keytext:Period; keychar:. (2e);modifrs: (0); loc:STANDARD; paramString:KEY_RELEASED,keyCode=46,keyText=Period,keyChar='.',keyLocation=KEY_LOCATION_STANDARD,rawCode=0,primaryLevelUnicode=0,scancode=0,extendedKeyCode=0x0 which seems someway bizarre.
09-08-2013

Note that keychar value (not very important (externally) in KEY_PRESSED) is different in the events: it is =, then +, then = again.
09-08-2013

8-defer-request: The issue is from 7 GA (7u6 on Mac OS X), isn't regression.
10-07-2013

The issue is reproduced in 1.7.0_06-b31 as well. ---------------- KEY PRESSED: key code = 157 (Meta) extended modifiers = 256 (Meta) action key? NO key location: left KEY PRESSED: key code = 61 (Equals) extended modifiers = 256 (Meta) action key? NO key location: standard KEY PRESSED: key code = 61 (Equals) extended modifiers = 256 (Meta) action key? NO key location: standard KEY PRESSED: key code = 61 (Equals) extended modifiers = 256 (Meta) action key? NO key location: standard KEY RELEASED: key code = 157 (Meta) extended modifiers = 0 (no extended modifiers) action key? NO key location: left -----------
10-07-2013

please verify, is it affecting 7u6 ?
10-07-2013