Java Code Examples for java.awt.event.KeyEvent#VK_SHIFT
The following examples show how to use
java.awt.event.KeyEvent#VK_SHIFT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Input.java From Spade with GNU General Public License v3.0 | 6 votes |
public void keyReleased(KeyEvent e) { if(e.getKeyCode() == KeyEvent.VK_CONTROL) { CTRL = false; } else if(e.getKeyCode() == KeyEvent.VK_SHIFT) { SHIFT = false; } else if(e.getKeyCode() == KeyEvent.VK_ALT) { ALT = false; } else if(e.getKeyCode() == KeyEvent.VK_SPACE) { robot.mouseRelease(InputEvent.BUTTON1_MASK); } }
Example 2
Source File: DesktopToolWindowManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
private static boolean areAllModifiersPressed(@JdkConstants.InputEventMask int modifiers, Set<Integer> modifierCodes) { int mask = 0; for (Integer each : modifierCodes) { if (each == KeyEvent.VK_SHIFT) { mask |= InputEvent.SHIFT_MASK; } if (each == KeyEvent.VK_CONTROL) { mask |= InputEvent.CTRL_MASK; } if (each == KeyEvent.VK_META) { mask |= InputEvent.META_MASK; } if (each == KeyEvent.VK_ALT) { mask |= InputEvent.ALT_MASK; } } return (modifiers ^ mask) == 0; }
Example 3
Source File: KeyShortCutEditPanel.java From netbeans-mmd-plugin with Apache License 2.0 | 6 votes |
private void textFieldKeyCodeKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_textFieldKeyCodeKeyPressed if (this.buttonEditKeyCode.isSelected()){ switch(evt.getKeyCode()){ case KeyEvent.VK_META: case KeyEvent.VK_ALT: case KeyEvent.VK_SHIFT: case KeyEvent.VK_CONTROL: evt.consume();break; default:{ updateCurrentSelectedForKey(evt); this.buttonEditKeyCode.setSelected(false); this.tableKeyShortcuts.requestFocus(); }break; } } evt.consume(); }
Example 4
Source File: ShortcutTextField.java From consulo with Apache License 2.0 | 6 votes |
@Override protected void processKeyEvent(KeyEvent e) { if (e.getID() == KeyEvent.KEY_PRESSED) { int keyCode = e.getKeyCode(); if ( keyCode == KeyEvent.VK_SHIFT || keyCode == KeyEvent.VK_ALT || keyCode == KeyEvent.VK_CONTROL || keyCode == KeyEvent.VK_ALT_GRAPH || keyCode == KeyEvent.VK_META ){ return; } setKeyStroke(KeyStrokeAdapter.getDefaultKeyStroke(e)); } }
Example 5
Source File: KeyMaskTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Override public void keyPressed(KeyEvent e) { keyPressReceived = true; int code = e.getKeyCode(); assertEQ(code, keyCode, "wrong key code"); int mask = 0; if (code == KeyEvent.VK_SHIFT) { mask = InputEvent.SHIFT_MASK; } else if (code == KeyEvent.VK_CONTROL) { mask = InputEvent.CTRL_MASK; } else if (code == KeyEvent.VK_ALT) { mask = InputEvent.ALT_MASK; } else if (code == KeyEvent.VK_META) { mask = InputEvent.META_MASK; } int mod = e.getModifiers() & mask; assertEQ(mod, mask, "invalid key mask"); synchronized (lock) { lock.notifyAll(); } }
Example 6
Source File: PopupManager.java From netbeans with Apache License 2.0 | 5 votes |
public @Override void keyPressed(KeyEvent e){ if (e != null && popup != null && popup.isShowing()) { // get popup's registered keyboard actions ActionMap am = popup.getActionMap(); InputMap im = popup.getInputMap(); // check whether popup registers keystroke KeyStroke ks = KeyStroke.getKeyStrokeForEvent(e); Object obj = im.get(ks); LOG.log(Level.FINE, "Keystroke for event {0}: {1}; action-map-key={2}", new Object [] { e, ks, obj }); //NOI18N if (shouldPopupReceiveForwardedKeyboardAction(obj)) { // if yes, gets the popup's action for this keystroke, perform it // and consume key event Action action = am.get(obj); LOG.log(Level.FINE, "Popup component''s action: {0}, {1}", new Object [] { action, action != null ? action.getValue(Action.NAME) : null }); //NOI18N /* Make sure to use the popup as the source of the action, since the popup is also providing the event. Not doing this, and instead invoking actionPerformed with a null ActionEvent, was one part of the problem seen in NETBEANS-403. */ if (SwingUtilities.notifyAction(action, ks, e, popup, e.getModifiers())) { e.consume(); return; } } if (e.getKeyCode() != KeyEvent.VK_CONTROL && e.getKeyCode() != KeyEvent.VK_SHIFT && e.getKeyCode() != KeyEvent.VK_ALT && e.getKeyCode() != KeyEvent.VK_ALT_GRAPH && e.getKeyCode() != KeyEvent.VK_META ) { // hide tooltip if any was shown Utilities.getEditorUI(textComponent).getToolTipSupport().setToolTipVisible(false); } } }
Example 7
Source File: KeyStrokeUtils.java From netbeans with Apache License 2.0 | 5 votes |
/** * Get human-readable name for a {@link KeyStroke}. */ public static String getKeyStrokeAsText(@NonNull KeyStroke keyStroke) { int modifiers = keyStroke.getModifiers (); StringBuilder sb = new StringBuilder (); if ((modifiers & InputEvent.CTRL_DOWN_MASK) > 0) { sb.append(EMACS_CTRL); } if ((modifiers & InputEvent.ALT_DOWN_MASK) > 0) { sb.append(STRING_ALT); } if ((modifiers & InputEvent.SHIFT_DOWN_MASK) > 0) { sb.append (EMACS_SHIFT); } if ((modifiers & InputEvent.META_DOWN_MASK) > 0) { sb.append(STRING_META); } if (keyStroke.getKeyCode () != KeyEvent.VK_SHIFT && keyStroke.getKeyCode () != KeyEvent.VK_CONTROL && keyStroke.getKeyCode () != KeyEvent.VK_META && keyStroke.getKeyCode () != KeyEvent.VK_ALT && keyStroke.getKeyCode () != KeyEvent.VK_ALT_GRAPH) { sb.append (Utilities.keyToString ( KeyStroke.getKeyStroke (keyStroke.getKeyCode (), 0) )); } return sb.toString (); }
Example 8
Source File: ShortcutListener.java From netbeans with Apache License 2.0 | 5 votes |
public void keyPressed(KeyEvent e) { assert (e.getSource() instanceof JTextField); if(((e.getModifiers() & (KeyEvent.ALT_MASK | KeyEvent.SHIFT_MASK | KeyEvent.CTRL_MASK | KeyEvent.META_MASK)) == 0) && (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_UP || e.getKeyCode() == KeyEvent.VK_ESCAPE)) { return ; } textField = (JTextField) e.getSource(); KeyStroke keyStroke = createKeyStroke(e); boolean add = e.getKeyCode() != KeyEvent.VK_SHIFT && e.getKeyCode() != KeyEvent.VK_CONTROL && e.getKeyCode() != KeyEvent.VK_ALT && e.getKeyCode() != KeyEvent.VK_META && e.getKeyCode() != KeyEvent.VK_ALT_GRAPH; if (!(enterConfirms && keyStroke.equals(enterKS))) { if (keyStroke.equals(backspaceKS) && !key.equals("")) { // delete last key int i = key.lastIndexOf(' '); //NOI18N if (i < 0) { key = ""; //NOI18N } else { key = key.substring(0, i); } textField.setText(key); } else { // add key addKeyStroke(keyStroke, add); } e.consume(); } }
Example 9
Source File: PolyTool.java From Logisim with GNU General Public License v3.0 | 5 votes |
@Override public void keyPressed(Canvas canvas, KeyEvent e) { int code = e.getKeyCode(); if (active && mouseDown && (code == KeyEvent.VK_SHIFT || code == KeyEvent.VK_CONTROL)) { updateMouse(canvas, lastMouseX, lastMouseY, e.getModifiersEx()); } }
Example 10
Source File: TrackControl.java From tracker with GNU General Public License v3.0 | 5 votes |
/** * Private constructor. * * @param panel the tracker panel to control */ private TrackControl(TrackerPanel panel) { super(panel.getTFrame(), false); // create GUI trackBarPanel = new JPanel(); setContentPane(trackBarPanel); shiftKeyListener = new KeyAdapter() { // transfers focus to trackerPanel for marking public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_SHIFT) { trackerPanel.requestFocus(); trackerPanel.requestFocusInWindow(); } else if (e.getKeyCode() == KeyEvent.VK_A) { MainTView mainView = trackerPanel.getTFrame().getMainView(trackerPanel); mainView.keyAdapter.keyPressed(e); trackerPanel.requestFocus(); trackerPanel.requestFocusInWindow(); } } }; setResizable(false); pack(); popup = new JPopupMenu(); trackerPanel = panel; trackerPanel.addPropertyChangeListener("track", this); //$NON-NLS-1$ trackerPanel.addPropertyChangeListener("clear", this); //$NON-NLS-1$ trackerPanel.addPropertyChangeListener("mass", this); //$NON-NLS-1$ trackerPanel.addPropertyChangeListener("footprint", this); //$NON-NLS-1$ trackerPanel.addPropertyChangeListener("data", this); //$NON-NLS-1$ // trackerPanel.addPropertyChangeListener("color", this); //$NON-NLS-1$ }
Example 11
Source File: LineTool.java From Logisim with GNU General Public License v3.0 | 5 votes |
@Override public void keyPressed(Canvas canvas, KeyEvent e) { int code = e.getKeyCode(); if (active && (code == KeyEvent.VK_SHIFT || code == KeyEvent.VK_CONTROL)) { updateMouse(canvas, lastMouseX, lastMouseY, e.getModifiersEx()); } }
Example 12
Source File: ModifierTracker.java From pumpernickel with MIT License | 5 votes |
public void eventDispatched(AWTEvent e) { if (e instanceof KeyEvent) { KeyEvent k = (KeyEvent) e; boolean pressed = k.getID() == KeyEvent.KEY_PRESSED; int code = k.getKeyCode(); switch (code) { case KeyEvent.VK_ALT: if (alt != pressed) { alt = pressed; fireAltChangeListeners(); } break; case KeyEvent.VK_ALT_GRAPH: if (altGraph != pressed) { altGraph = pressed; fireAltGraphChangeListeners(); } break; case KeyEvent.VK_META: if (meta != pressed) { meta = pressed; fireMetaChangeListeners(); } break; case KeyEvent.VK_SHIFT: if (shift != pressed) { shift = pressed; fireShiftChangeListeners(); } break; case KeyEvent.VK_CONTROL: if (ctrl != pressed) { ctrl = pressed; fireControlChangeListeners(); } break; } } }
Example 13
Source File: BarbarianAssaultPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_SHIFT) { shiftDown = true; } if (e.getKeyCode() == KeyEvent.VK_CONTROL) { controlDown = true; } }
Example 14
Source File: WSRecorder.java From marathonv5 with Apache License 2.0 | 5 votes |
@Override public void recordRawKeyEvent(RComponent r, KeyEvent e) { JSONObject event = new JSONObject(); event.put("type", "key_raw"); int keyCode = e.getKeyCode(); if (keyCode == KeyEvent.VK_META || keyCode == KeyEvent.VK_SHIFT || keyCode == KeyEvent.VK_ALT || keyCode == KeyEvent.VK_CONTROL) { return; } if ((e.isActionKey() || e.isControlDown() || e.isMetaDown() || e.isAltDown()) && e.getID() == KeyEvent.KEY_PRESSED) { String mtext = buildModifiersText(e); event.put("modifiersEx", mtext); KeysMap keysMap = KeysMap.findMap(e.getKeyCode()); if (keysMap == KeysMap.NULL) { return; } String keyText; if (keysMap == null) { keyText = KeyEvent.getKeyText(e.getKeyCode()); } else { keyText = keysMap.toString(); } event.put("keyCode", keyText); } else if (e.getID() == KeyEvent.KEY_TYPED && !e.isControlDown()) { if (Character.isISOControl(e.getKeyChar()) && hasMapping(e.getKeyChar())) { event.put("keyChar", getMapping(e.getKeyChar())); } else { event.put("keyChar", "" + e.getKeyChar()); } } else { return; } recordEvent(r, event); }
Example 15
Source File: PhotoEditorPanel.java From mvisc with GNU General Public License v3.0 | 5 votes |
public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_SHIFT) { shiftDown = true; } if (e.getKeyCode() == KeyEvent.VK_CONTROL) { controlDown = true; } }
Example 16
Source File: SelectTool.java From Logisim with GNU General Public License v3.0 | 5 votes |
@Override public void keyReleased(Canvas canvas, KeyEvent e) { if (state == MOVING && e.getKeyCode() == KeyEvent.VK_SHIFT) { handleMoveDrag(canvas, curDx, curDy, e.getModifiersEx()); } else { processKeyEvent(canvas, e, KeyConfigurationEvent.KEY_RELEASED); } }
Example 17
Source File: PlotBox.java From OpenDA with GNU Lesser General Public License v3.0 | 5 votes |
public void keyReleased(KeyEvent e) { int keycode = e.getKeyCode(); switch(keycode) { case KeyEvent.VK_CONTROL: _control = false; break; case KeyEvent.VK_SHIFT: _shift = false; break; default: // None } }
Example 18
Source File: ReservedKeyBindings.java From ghidra with Apache License 2.0 | 5 votes |
public static boolean isReservedKeystroke(KeyStroke keyStroke) { int code = keyStroke.getKeyCode(); if (code == KeyEvent.VK_SHIFT || code == KeyEvent.VK_ALT || code == KeyEvent.VK_CONTROL || code == KeyEvent.VK_CAPS_LOCK || code == KeyEvent.VK_TAB || HELP_KEY1.equals(keyStroke) || HELP_KEY2.equals(keyStroke) || HELP_INFO_KEY.equals(keyStroke) || UPDATE_KEY_BINDINGS_KEY.equals(keyStroke) || FOCUS_INFO_KEY.equals(keyStroke) || FOCUS_CYCLE_INFO_KEY.equals(keyStroke)) { return true; } return false; }
Example 19
Source File: VncClientPacketSender.java From cloudstack with Apache License 2.0 | 4 votes |
private int mapAwtKeyToVncKey(int key) { switch (key) { case KeyEvent.VK_BACK_SPACE: return 0xff08; case KeyEvent.VK_TAB: return 0xff09; case KeyEvent.VK_ENTER: return 0xff0d; case KeyEvent.VK_ESCAPE: return 0xff1b; case KeyEvent.VK_INSERT: return 0xff63; case KeyEvent.VK_DELETE: return 0xffff; case KeyEvent.VK_HOME: return 0xff50; case KeyEvent.VK_END: return 0xff57; case KeyEvent.VK_PAGE_UP: return 0xff55; case KeyEvent.VK_PAGE_DOWN: return 0xff56; case KeyEvent.VK_LEFT: return 0xff51; case KeyEvent.VK_UP: return 0xff52; case KeyEvent.VK_RIGHT: return 0xff53; case KeyEvent.VK_DOWN: return 0xff54; case KeyEvent.VK_F1: return 0xffbe; case KeyEvent.VK_F2: return 0xffbf; case KeyEvent.VK_F3: return 0xffc0; case KeyEvent.VK_F4: return 0xffc1; case KeyEvent.VK_F5: return 0xffc2; case KeyEvent.VK_F6: return 0xffc3; case KeyEvent.VK_F7: return 0xffc4; case KeyEvent.VK_F8: return 0xffc5; case KeyEvent.VK_F9: return 0xffc6; case KeyEvent.VK_F10: return 0xffc7; case KeyEvent.VK_F11: return 0xffc8; case KeyEvent.VK_F12: return 0xffc9; case KeyEvent.VK_SHIFT: return 0xffe1; case KeyEvent.VK_CONTROL: return 0xffe3; case KeyEvent.VK_META: return 0xffe7; case KeyEvent.VK_ALT: return 0xffe9; case KeyEvent.VK_ALT_GRAPH: return 0xffea; case KeyEvent.VK_BACK_QUOTE: return 0x0060; } return key; }
Example 20
Source File: View2D.java From energy2d with GNU Lesser General Public License v3.0 | 4 votes |
private void processKeyPressed(KeyEvent e) { if (runHeatingThread) { if (e.getKeyCode() == KeyEvent.VK_SHIFT) { cooling = true; } } boolean shiftDown = e.isShiftDown(); float delta = snapToGrid ? (shiftDown ? 5 : 1) : (shiftDown ? 2.5f : 0.25f); boolean showTip = false; switch (e.getKeyCode()) { case KeyEvent.VK_LEFT: delta *= -(xmax - xmin) / nx; if (selectedManipulable != null) { translateManipulableBy(selectedManipulable, delta, 0); showTip = true; } else if (e.isAltDown()) { translateAllBy(delta, 0); showTip = true; undoManager.addEdit(new UndoTranslateAll(this, e.getKeyCode(), delta)); } break; case KeyEvent.VK_RIGHT: delta *= (xmax - xmin) / nx; if (selectedManipulable != null) { translateManipulableBy(selectedManipulable, delta, 0); showTip = true; } else if (e.isAltDown()) { translateAllBy(delta, 0); showTip = true; undoManager.addEdit(new UndoTranslateAll(this, e.getKeyCode(), delta)); } break; case KeyEvent.VK_DOWN: delta *= (ymax - ymin) / ny; if (selectedManipulable != null) { translateManipulableBy(selectedManipulable, 0, delta); showTip = true; } else if (e.isAltDown()) { translateAllBy(0, delta); showTip = true; undoManager.addEdit(new UndoTranslateAll(this, e.getKeyCode(), delta)); } break; case KeyEvent.VK_UP: delta *= -(ymax - ymin) / ny; if (selectedManipulable != null) { translateManipulableBy(selectedManipulable, 0, delta); showTip = true; } else if (e.isAltDown()) { translateAllBy(0, delta); showTip = true; undoManager.addEdit(new UndoTranslateAll(this, e.getKeyCode(), delta)); } break; } if (showTip && !shiftDown) { tipText = "Hold down SHIFT key to move faster"; } if (showGrid) { int gridSize = gridRenderer.getGridSize(); if (e.isAltDown()) { switch (e.getKeyChar()) { case ']': if (gridSize < GridRenderer.MAX_GRID_SIZE) gridRenderer.setGridSize(++gridSize); break; case '[': if (gridSize > GridRenderer.MIN_GRID_SIZE) gridRenderer.setGridSize(--gridSize); break; } } } setSelectedManipulable(selectedManipulable); repaint(); // e.consume();//don't call, or this stops key binding }