JDK-8152494 : [macosx swing] Should Mac command key map to InputEvent.CTRL_MASK?
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7u6,8,9
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: os_x
  • Submitted: 2016-03-23
  • Updated: 2016-04-01
  • Resolved: 2016-04-01
Related Reports
Relates :  
Relates :  
Description
Should the Mac command key map to InputEvent.CTRL_MASK?

Having to use control instead of command causes problems for VoiceOver users, e.g. for the first two sets of commands.
- control option: First Level VO Commands. 
- control option shift: Second Level VO Commands
- control option command: Third Level VO Commands
- control option shift command: Fourth Level VO Commands

If command mapped to InputEvent.CTRL_MASK that would eliminate the conflict.  Java apps could then use all of the following without conflicting with VO keys.
- command aKey
- command option aKey
- command shift aKey
- command option shift aKey

and use of the command key is consistent with the Mac shortcut standard.

Also, if "apple.laf.useScreenMenuBar" is off, control F2 moves focus to the menu bar.  So even without VO there is that side effect when using a shortcut/accelerator of  control (plus other optional modifiers) F2.  If command was mapped to control that conflict would be removed.

I suspect that even if "apple.laf.useScreenMenuBar" was on, control F2 might move to the menu bar but at least visually I didn't see it, perhaps due to other interactions with that menu bar, interactions that would otherwise be happening on the Swing menu bar.
Comments
The CMD key is not an equivalent of CTRL, on OSX these are two different keys, and each of them can be set as a shortcuts. We cannot change this for a developer. There is an option for some standard shortcuts like ctrl+c/v, they are controlled by Look and Feel. For example the Aqua L&F changes them to cmd+c/v. But we cannot do it ourself in some general way.
01-04-2016

The equivalent to the key labeled Ctrl on a PC keyboard is the Mac key labeled command, not the key labeled control. I see that when the command key is pressed it is the META input event. Do we require that a developer must sense for OS X and change the InputEvents from CTRL_MASK to META_MASK? Is there any way to automate this or ease this platform difference adaptation for the developer? The problem with apps that use the CTRL input event is that this causes conflicts as I pointed out, i.e. conflicts with VO short cuts and control F2 to move to the top of screen menu. Also, the command key is the standard shortcut key on the Mac.
25-03-2016

I guess we cannot map cmd -> to ctrl because it is actually a different buttons. Can you please clarify the problem, why even now we application cannot set cmd(META_DOWN_MASK) or any keys as a shortcuts and use them?
24-03-2016