InputEvent.CTRL_MASK ignores keyboard layout on OS X
Tim Howe
tim.howe at bloodhoundcbc.com
Fri Oct 18 11:35:58 PDT 2013
Unfortunately there seems to be a regression in key event handling in Java
1.7+ on OS X.
Mapping actions to control-chorded keystrokes uses what's printed on the
physical key regardless of the selected keyboard layout. Therefore when
using any other keyboard layout the specified control keys don't work and
other keys have surprising effects. If you add a KeyListener and examine
the KeyEvent it is incorrect as well.
This only affects CTRL_MASK and only Java 1.7 and so far 1.8. 1.6 works
correctly.
Here are 2 simple ways to duplicate the problem:
* Simple test case:
1. Download and compile
http://www.java2s.com/Code/JavaAPI/java.awt.event/InputEventCTRLMASK.htm
2. Select Dvorak keyboard layout ("input source")
4. Run sample code
5. Press Control-U (will appear to be Control-F on keyboard); note caret
moves forward 1 character
6. Press Control-G (will appear to be Control-U on keyboard); note word is
uppercased
If you replace all instances of CTRL_MASK with META_MASK the code works as
expected.
* Simpler test case:
1. Use Dvorak or some other alternate keyboard layout
2. Run NetBeans
3. Try to use control keys and notice that your source code is munged
unpredictably
Thanks,
Tim
This email message, including any attachment(s), is for the sole use of the intended recipient(s) and may contain confidential and legally privileged information. If you believe that you are not an intended recipient of this message, please contact the sender by reply email and destroy all copies of the original message. Any unauthorized use, dissemination, or reproduction of this message by anyone other than an intended recipient is strictly prohibited. BLOODHOUND is a trademark of Constitution Medical, Inc.
More information about the macosx-port-dev
mailing list