@@ -129,7 +129,7 @@ public InputHandler copy() {
129129 */
130130 public void keyPressed (KeyEvent evt ) {
131131 int keyCode = evt .getKeyCode ();
132- int modifiers = evt .getModifiers ();
132+ int modifiers = evt .getModifiersEx ();
133133
134134 // moved this earlier so it doesn't get random meta clicks
135135 if (keyCode == KeyEvent .VK_CONTROL ||
@@ -141,14 +141,14 @@ public void keyPressed(KeyEvent evt) {
141141
142142 // Don't get command-s or other menu key equivalents on macOS
143143 // unless it's something that's specifically bound (cmd-left or right)
144- if ((modifiers & InputEvent .META_MASK ) != 0 ) {
144+ if ((modifiers & InputEvent .META_DOWN_MASK ) != 0 ) {
145145 KeyStroke keyStroke = KeyStroke .getKeyStroke (keyCode , modifiers );
146146 if (bindings .get (keyStroke ) == null ) {
147147 return ;
148148 }
149149 }
150150
151- if ((modifiers & ~InputEvent .SHIFT_MASK ) != 0
151+ if ((modifiers & ~InputEvent .SHIFT_DOWN_MASK ) != 0
152152 || evt .isActionKey ()
153153 || keyCode == KeyEvent .VK_BACK_SPACE
154154 || keyCode == KeyEvent .VK_DELETE
@@ -174,16 +174,16 @@ public void keyPressed(KeyEvent evt) {
174174 * Handle a key typed event. This inserts the key into the text area.
175175 */
176176 public void keyTyped (KeyEvent evt ) {
177- int modifiers = evt .getModifiers ();
177+ int modifiers = evt .getModifiersEx ();
178178 char c = evt .getKeyChar ();
179179
180180 // This is the cmd key on macOS. Added this because
181181 // menu shortcuts were being passed through as legit keys.
182- if ((modifiers & InputEvent .META_MASK ) != 0 ) return ;
182+ if ((modifiers & InputEvent .META_DOWN_MASK ) != 0 ) return ;
183183
184184 // Prevent CTRL-/ from going through as a typed '/' character
185185 // http://code.google.com/p/processing/issues/detail?id=596
186- if ((modifiers & InputEvent .CTRL_MASK ) != 0 && c == '/' ) return ;
186+ if ((modifiers & InputEvent .CTRL_DOWN_MASK ) != 0 && c == '/' ) return ;
187187
188188 if (c != KeyEvent .CHAR_UNDEFINED ) {
189189 if (c >= 0x20 && c != 0x7f ) {
@@ -236,16 +236,16 @@ static public KeyStroke parseKeyStroke(String keyStroke) {
236236 for (int i = 0 ; i < index ; i ++) {
237237 switch (Character .toUpperCase (keyStroke .charAt (i ))) {
238238 case 'A' :
239- modifiers |= InputEvent .ALT_MASK ;
239+ modifiers |= InputEvent .ALT_DOWN_MASK ;
240240 break ;
241241 case 'C' :
242- modifiers |= InputEvent .CTRL_MASK ;
242+ modifiers |= InputEvent .CTRL_DOWN_MASK ;
243243 break ;
244244 case 'M' :
245- modifiers |= InputEvent .META_MASK ;
245+ modifiers |= InputEvent .META_DOWN_MASK ;
246246 break ;
247247 case 'S' :
248- modifiers |= InputEvent .SHIFT_MASK ;
248+ modifiers |= InputEvent .SHIFT_DOWN_MASK ;
249249 break ;
250250 }
251251 }
0 commit comments