List of usage examples for java.awt.event KeyEvent VK_CONTROL
int VK_CONTROL
To view the source code for java.awt.event KeyEvent VK_CONTROL.
Click Source Link
From source file:com.tradedesksoftware.ets.client.charting.ChartShiftController.java
public void keyReleased(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_CONTROL) chartPanel.setCursor(ARROW); }
From source file:com.netease.dagger.BrowserEmulator.java
/** * Close previous tab in browser/*from w ww. j a va 2 s . c o m*/ */ public void closePreviousTAB() { pause(stepInterval); try { Robot robot = new Robot(); robot.keyPress(KeyEvent.VK_CONTROL); robot.keyPress(KeyEvent.VK_PAGE_UP); robot.keyRelease(KeyEvent.VK_CONTROL); robot.keyRelease(KeyEvent.VK_PAGE_UP); robot.keyPress(KeyEvent.VK_CONTROL); robot.keyPress(KeyEvent.VK_W); robot.keyRelease(KeyEvent.VK_CONTROL); robot.keyRelease(KeyEvent.VK_W); } catch (Exception e) { e.printStackTrace(); handleFailure("Failed to close previous TAB"); } logger.info("Success to close previous TAB"); }
From source file:com.fanniemae.ezpie.actions.HighlightScan.java
private void keyPressReleaseControlA(int delay) { _robot.keyPress(KeyEvent.VK_CONTROL); _robot.keyPress(KeyEvent.VK_A); sleep(delay);/*from w w w.j a v a 2s. c o m*/ _robot.keyRelease(KeyEvent.VK_CONTROL); _robot.keyRelease(KeyEvent.VK_A); }
From source file:edu.ku.brc.af.ui.db.TextFieldWithQuery.java
/** * Processes the KeyEvent./*from w ww . j a va 2s. c om*/ * @param ev event */ protected void cbxKeyReleased(KeyEvent ev) { if (isReadOnlyMode) { return; } if (ev.getKeyCode() == KeyEvent.VK_SHIFT || ev.getKeyCode() == KeyEvent.VK_LEFT || ev.getKeyCode() == KeyEvent.VK_RIGHT || ev.getKeyCode() == KeyEvent.VK_CONTROL || ev.getKeyCode() == KeyEvent.VK_META) { return; } currentText = textField.getText(); if (uiFieldFormatter != null) { currentText = uiFieldFormatter.formatFromUI(currentText).toString(); } if (currentText.length() == 0 || !hasNewText) { if (ev.getKeyCode() == KeyEvent.VK_TAB) { if (ev.isShiftDown()) { textField.transferFocusBackward(); } else { textField.transferFocus(); } return; } if (ev.getKeyCode() == JAutoCompComboBox.SEARCH_KEY || ev.getKeyCode() == KeyEvent.VK_DOWN) { showPopup(0); // add only return; } if (ev.getKeyCode() != KeyEvent.VK_ENTER) { // Add variable to track whether it once had a value and now it does not rods - 02/28/08 idList.clear(); list.clear(); selectedId = null; // 02/09/08 - This should not be done here - rods // The reason is, that we may have added something only to remove // before leaving the control. So we should never send the notification // just because we delete the contents. (see wasCleared above) /*if (listSelectionListeners != null) { notifyListenersOfChange(TextFieldWithQuery.this); }*/ //log.debug("setting hasNewText to true"); //$NON-NLS-1$ hasNewText = true; } } else { hasNewText = true; //log.debug("setting hasNewText to true"); } if (ev.getKeyCode() == JAutoCompComboBox.SEARCH_KEY || ev.getKeyCode() == KeyEvent.VK_TAB || ev.getKeyCode() == KeyEvent.VK_DOWN) { String origText = textField.getText(); String text = origText; if (uiFieldFormatter != null && !uiFieldFormatter.isNumeric()) { text = uiFieldFormatter.formatFromUI(text).toString(); } text = StringUtils.replace(text, "'", "\'"); text = StringUtils.replace(text, "\"", "\\\""); // direction of focus change 1: forward 0: none -1: backwards int focusChange = (ev.isShiftDown() ? -1 : 1) * (ev.getKeyCode() == KeyEvent.VK_TAB ? 1 : 0); doQuery(text, origText, focusChange); } }
From source file:com.seleniumtests.driver.CustomEventFiringWebDriver.java
/** * Use copy to clipboard and copy-paste keyboard shortcut to write something on upload window *//*from w w w . j av a2 s . c o m*/ public static void uploadFileUsingClipboard(File tempFile) { // Copy to clipboard Toolkit.getDefaultToolkit().getSystemClipboard() .setContents(new StringSelection(tempFile.getAbsolutePath()), null); Robot robot; try { robot = new Robot(); WaitHelper.waitForSeconds(1); // // Press Enter // robot.keyPress(KeyEvent.VK_ENTER); // // // Release Enter // robot.keyRelease(KeyEvent.VK_ENTER); // Press CTRL+V robot.keyPress(KeyEvent.VK_CONTROL); robot.keyPress(KeyEvent.VK_V); // Release CTRL+V robot.keyRelease(KeyEvent.VK_CONTROL); robot.keyRelease(KeyEvent.VK_V); WaitHelper.waitForSeconds(1); // Press Enter robot.keyPress(KeyEvent.VK_ENTER); robot.keyRelease(KeyEvent.VK_ENTER); } catch (AWTException e) { throw new ScenarioException("could not initialize robot to upload file: " + e.getMessage()); } }
From source file:com.all.login.view.NewAccountFormPanel.java
JTextField getEmailTextField() { if (emailTextField == null) { emailTextField = new JTextField(); emailTextField.setBounds(EMAIL_TEXTFIELD_BOUNDS); emailTextField.setSelectionColor(COLOR_SELECTION_TEXTFIELDS); emailTextField.setName(EMAIL_TEXT_FIELD_NAME); final LowercaseFocusListener emailListener = new LowercaseFocusListener(emailTextField, EMAIL_FIELD_NAME);/*from ww w .j a v a2s .c o m*/ emailTextField.addFocusListener(emailListener); emailTextField.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { int caretPosition = emailTextField.getCaretPosition(); if (emailTextField.getName().startsWith(INVALID_FIELD_NAME)) { emailListener.focusLost(null); } validateAllUserData(); emailTextField.setCaretPosition(caretPosition); } }); InputMap map = emailTextField.getInputMap(JTextField.WHEN_FOCUSED); map.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.VK_CONTROL), null); emailTextField.addKeyListener(new CopyPasteKeyAdapterForMac()); } return emailTextField; }
From source file:com.jcraft.weirdx.DDXWindowImpSwing.java
public void keyPressed(KeyEvent e) { if (!window.isMapped()) return;/*from ww w . j a va2 s . c o m*/ if (e.getKeyCode() == KeyEvent.VK_CAPS_LOCK) { if (clck_toggle) { clck_toggle = false; XWindow.sprite.hot.state &= (~1); } else { clck_toggle = true; XWindow.sprite.hot.state |= 1; } } // Easter Egg... if (window == window.screen.root && 0 < px && px < 3 && 0 < py && py < 3) { if (((e.getModifiers() & InputEvent.CTRL_MASK) != 0) && e.getKeyCode() == KeyEvent.VK_W) { LogoImage.toggle(); } else if (((e.getModifiers() & InputEvent.CTRL_MASK) != 0) && e.getKeyCode() == KeyEvent.VK_E) { XWindow.printWindowTree(window.screen.root); } // else if(((e.getModifiers() & InputEvent.CTRL_MASK)!=0) && // e.getKeyCode()==KeyEvent.VK_I){ // if(WeirdX.acontext!=null){ // acontext.showDocument(new URL("http://www.weirdx.org/"), "_blank"); // } // } // else if(((e.getModifiers() & InputEvent.CTRL_MASK)!=0) && // e.getKeyCode()==KeyEvent.VK_R){ // } // } // else if(((e.getModifiers() & InputEvent.CTRL_MASK)!=0) && // e.getKeyCode()==KeyEvent.VK_D){ // } // } // else if(((e.getModifiers() & InputEvent.CTRL_MASK)!=0) && // e.getKeyCode()==KeyEvent.VK_X){ // } // } } XWindow dest = XWindow.sprite.win; if (XWindow.focus.window != null) dest = XWindow.focus.window; if (window.screen.windowmode != 0 && dest == window.screen.root) { if (XWindow.focus.window != null) dest = XWindow.sprite.win; else dest = window; } if (dest.client == null) return; int kcode = Keymap.km.getCode(e); event.mkKeyPress(kcode, window.screen.rootId, dest.id, 0, XWindow.sprite.hot.x, XWindow.sprite.hot.y, XWindow.sprite.hot.x - window.x, XWindow.sprite.hot.y - window.y, XWindow.sprite.hot.state, 1); try { if (XWindow.grab != null) XWindow.sendGrabbedEvent(event, false, 1); else XWindow.sendDeviceEvent(dest, event, XWindow.grab, null, 1); } catch (Exception ee) { } kcode = e.getKeyCode(); int state = XWindow.sprite.hot.state; if (kcode == KeyEvent.VK_CONTROL) { if ((state & 4) == 0) state |= 4; } else if (kcode == KeyEvent.VK_SHIFT) { if ((state & 1) == 0) state |= 1; } else if (kcode == KeyEvent.VK_ALT) { if ((state & 8) == 0) state |= 8; } else if (kcode == VK_ALT_GRAPH) { if ((state & ALT_GR_MASK) == 0) state |= ALT_GR_MASK; } // check for windoze ALT_GR (is equal to ALT+CONTROL), by Marcus. if ((state & 12) == 12) { state -= 12; state |= ALT_GR_MASK; } XWindow.sprite.hot.state = state; }
From source file:com.jcraft.weirdx.DDXWindowImp.java
public void keyPressed(KeyEvent e) { if (!window.isMapped()) return;/*from w ww .j a v a 2 s . co m*/ if (e.getKeyCode() == KeyEvent.VK_CAPS_LOCK) { if (clck_toggle) { clck_toggle = false; XWindow.sprite.hot.state &= (~1); } else { clck_toggle = true; XWindow.sprite.hot.state |= 1; } } // Easter Egg... if (window == window.screen.root && 0 < px && px < 3 && 0 < py && py < 3) { if (((e.getModifiers() & InputEvent.CTRL_MASK) != 0) && e.getKeyCode() == KeyEvent.VK_W) { LogoImage.toggle(); } else if (((e.getModifiers() & InputEvent.CTRL_MASK) != 0) && e.getKeyCode() == KeyEvent.VK_E) { XWindow.printWindowTree(window.screen.root); } // else if(((e.getModifiers() & InputEvent.CTRL_MASK)!=0) && // e.getKeyCode()==KeyEvent.VK_I){ // if(WeirdX.acontext!=null){ // acontext.showDocument(new URL("http://www.weirdx.org/"), "_blank"); // } // } // else if(((e.getModifiers() & InputEvent.CTRL_MASK)!=0) && // e.getKeyCode()==KeyEvent.VK_R){ // } // } // else if(((e.getModifiers() & InputEvent.CTRL_MASK)!=0) && // e.getKeyCode()==KeyEvent.VK_D){ // } // } // else if(((e.getModifiers() & InputEvent.CTRL_MASK)!=0) && // e.getKeyCode()==KeyEvent.VK_X){ // } // } } XWindow dest = XWindow.sprite.win; if (XWindow.focus.window != null) dest = XWindow.focus.window; if (window.screen.windowmode != 0 && dest == window.screen.root) { if (XWindow.focus.window != null) dest = XWindow.sprite.win; else dest = window; } if (dest.client == null) return; int kcode = Keymap.km.getCode(e); event.mkKeyPress(kcode, window.screen.rootId, dest.id, 0, XWindow.sprite.hot.x, XWindow.sprite.hot.y, XWindow.sprite.hot.x - window.x, XWindow.sprite.hot.y - window.y, XWindow.sprite.hot.state, 1); try { if (XWindow.grab != null) XWindow.sendGrabbedEvent(event, false, 1); else XWindow.sendDeviceEvent(dest, event, XWindow.grab, null, 1); } catch (Exception ee) { } kcode = e.getKeyCode(); int state = XWindow.sprite.hot.state; if (kcode == KeyEvent.VK_CONTROL) { if ((state & 4) == 0) state |= 4; } else if (kcode == KeyEvent.VK_SHIFT) { if ((state & 1) == 0) state |= 1; } else if (kcode == KeyEvent.VK_ALT) { if ((state & 8) == 0) state |= 8; } else if (kcode == VK_ALT_GRAPH) { if ((state & ALT_GR_MASK) == 0) state |= ALT_GR_MASK; } // check for windoze ALT_GR (is equal to ALT+CONTROL) if ((state & 12) == 12) { state -= 12; state |= ALT_GR_MASK; } XWindow.sprite.hot.state = state; }
From source file:com.jcraft.weirdx.DDXWindowImpSwing.java
public void keyReleased(KeyEvent e) { if ((window == null) || (!window.isMapped())) return;/* ww w . jav a2 s . c om*/ Client client = window.client; if (client == null) return; int kcode = Keymap.km.getCode(e); event.mkKeyRelease(kcode, window.screen.rootId, window.id, 0, XWindow.sprite.hot.x, XWindow.sprite.hot.y, XWindow.sprite.hot.x - window.x, XWindow.sprite.hot.y - window.y, XWindow.sprite.hot.state, // state, 1); try { if (XWindow.grab != null) XWindow.sendGrabbedEvent(event, false, 1); else XWindow.sendDeviceEvent(window, event, XWindow.grab, null, 1); } catch (Exception ee) { } kcode = e.getKeyCode(); int state = XWindow.sprite.hot.state; if (kcode == KeyEvent.VK_CONTROL) { if ((state & 4) != 0) state -= 4; // check for windoze ALT_GR (is equal to ALT+CONTROL), by Marcus. if ((state & ALT_GR_MASK) != 0) state -= ALT_GR_MASK; } else if (kcode == KeyEvent.VK_SHIFT && !clck_toggle) { if ((state & 1) != 0) state -= 1; } else if (kcode == KeyEvent.VK_ALT) { if ((state & 8) != 0) state -= 8; } else if (kcode == VK_ALT_GRAPH) { if ((state & ALT_GR_MASK) != 0) state -= ALT_GR_MASK; } XWindow.sprite.hot.state = state; }
From source file:com.jcraft.weirdx.DDXWindowImp.java
public void keyReleased(KeyEvent e) { if ((window == null) || (!window.isMapped())) return;//from www . j a va 2s . c o m Client client = window.client; if (client == null) return; int kcode = Keymap.km.getCode(e); event.mkKeyRelease(kcode, window.screen.rootId, window.id, 0, XWindow.sprite.hot.x, XWindow.sprite.hot.y, XWindow.sprite.hot.x - window.x, XWindow.sprite.hot.y - window.y, XWindow.sprite.hot.state, // state, 1); try { if (XWindow.grab != null) XWindow.sendGrabbedEvent(event, false, 1); else XWindow.sendDeviceEvent(window, event, XWindow.grab, null, 1); } catch (Exception ee) { } // change key state kcode = e.getKeyCode(); int state = XWindow.sprite.hot.state; if (kcode == KeyEvent.VK_CONTROL) { if ((state & 4) != 0) state -= 4; // check for windoze ALT_GR (is equal to ALT+CONTROL) if ((state & ALT_GR_MASK) != 0) state -= ALT_GR_MASK; } else if (kcode == KeyEvent.VK_SHIFT && !clck_toggle) { if ((state & 1) != 0) state -= 1; } else if (kcode == KeyEvent.VK_ALT) { if ((state & 8) != 0) state -= 8; } else if (kcode == VK_ALT_GRAPH) { if ((state & ALT_GR_MASK) != 0) state -= ALT_GR_MASK; } XWindow.sprite.hot.state = state; }