@Override public void keyPressed(final KeyEvent e) { if (!(e.isAltDown() || e.isMetaDown() || e.isControlDown() || myPanel.isNodePopupActive())) { if (!Character.isLetter(e.getKeyChar())) { return; } final IdeFocusManager focusManager = IdeFocusManager.getInstance(myPanel.getProject()); final ActionCallback firstCharTyped = new ActionCallback(); focusManager.typeAheadUntil(firstCharTyped); myPanel.moveDown(); //noinspection SSBasedInspection SwingUtilities.invokeLater( new Runnable() { public void run() { try { final Robot robot = new Robot(); final boolean shiftOn = e.isShiftDown(); final int code = e.getKeyCode(); if (shiftOn) { robot.keyPress(KeyEvent.VK_SHIFT); } robot.keyPress(code); robot.keyRelease(code); // don't release Shift firstCharTyped.setDone(); } catch (AWTException ignored) { } } }); } }
/** * Method declaration * * @param k */ public void keyTyped(KeyEvent k) { if (k.getKeyChar() == '\n' && k.isControlDown()) { k.consume(); execute(); } }
public void keyPressed(KeyEvent event) { msg1 = ""; System.out.println("keyPressed " + event.getKeyCode()); if (event.getKeyChar() == KeyEvent.CHAR_UNDEFINED) { int key = event.getKeyCode(); // Funktionstaste abfragen if (key == KeyEvent.VK_F1) { msg1 = "F1"; } else if (key == KeyEvent.VK_F2) { msg1 = "F2"; } else if (key == KeyEvent.VK_F3) { msg1 = "F3"; } // Modifier abfragen if (msg1.length() > 0) { if (event.isAltDown()) { msg1 = "ALT + " + msg1; } if (event.isControlDown()) { msg1 = "STRG + " + msg1; } if (event.isShiftDown()) { msg1 = "UMSCHALT + " + msg1; } } } repaint(); }
/** * The keyReleased event ensures that the caret-position is updated for both peers, when the * user moves the caret with the arrow-keys. */ public void keyReleased(KeyEvent e) { int left = e.VK_LEFT; int right = e.VK_RIGHT; int up = e.VK_UP; int down = e.VK_DOWN; int home = e.VK_HOME; int end = e.VK_END; int A = e.VK_A; int kc = e.getKeyCode(); if (kc == left || kc == right || kc == up || kc == down || kc == home || kc == end || (kc == A && e.isControlDown())) { if (dec == null) return; lc.increment(); TextEvent cu = new CaretUpdate(area1.getCaretPosition(), lc.getTimeStamp()); dec.sendObjectToAllPeers(cu); er.getEventHistoryLock().lock(); er.getEventHistory().add(cu); er.getEventHistoryLock().unlock(); } }
public void processKeyEvent(KeyEvent evt) { evt = KeyEventWorkaround.processKeyEvent(evt); if (evt == null) return; switch (evt.getID()) { case KeyEvent.KEY_TYPED: char ch = evt.getKeyChar(); if (!nonDigit && Character.isDigit(ch)) { super.processKeyEvent(evt); repeat = true; repeatCount = Integer.parseInt(action.getText()); } else { nonDigit = true; if (repeat) { passToView(evt); } else super.processKeyEvent(evt); } break; case KeyEvent.KEY_PRESSED: int keyCode = evt.getKeyCode(); if (evt.isActionKey() || evt.isControlDown() || evt.isAltDown() || evt.isMetaDown() || keyCode == KeyEvent.VK_BACK_SPACE || keyCode == KeyEvent.VK_DELETE || keyCode == KeyEvent.VK_ENTER || keyCode == KeyEvent.VK_TAB || keyCode == KeyEvent.VK_ESCAPE) { nonDigit = true; if (repeat) { passToView(evt); break; } else if (keyCode == KeyEvent.VK_TAB) { complete(true); evt.consume(); } else if (keyCode == KeyEvent.VK_ESCAPE) { evt.consume(); if (popup != null) { popup.dispose(); popup = null; action.requestFocus(); } else { if (temp) view.removeToolBar(ActionBar.this); view.getEditPane().focusOnTextArea(); } break; } else if ((keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_DOWN) && popup != null) { popup.list.processKeyEvent(evt); break; } } super.processKeyEvent(evt); break; } }
/** * Used for incremental search. Only activated when incremental is selected. * * <p>The variable incSearchPos keeps track of which entry was last checked. */ @Override public void keyTyped(KeyEvent e) { if (e.isControlDown()) { return; } if (panel != null) { goIncremental(); } }
// Special case for OS X, where Ctrl-Space is not detected as KEY_TYPED // https://github.com/processing/processing/issues/2699 private void processControlSpace(final KeyEvent event) { if (event.getKeyCode() == KeyEvent.VK_SPACE && event.isControlDown()) { // Provide completions only if it's enabled if (JavaMode.codeCompletionsEnabled) { Messages.log( "[KeyEvent]" + KeyEvent.getKeyText(event.getKeyCode()) + " |Prediction started"); fetchPhrase(); } } }
/** * handle event * * @param e event */ public void keyReleased(KeyEvent e) { if (e.isControlDown() && (e.getKeyCode() == KeyEvent.VK_P)) { List selectionSet = getSelection(); if (selectionSet.size() == 1) { showProperties((MetSymbol) selectionSet.get(0)); } return; } super.keyReleased(e); }
public void keyReleased(KeyEvent e) { Node node = Core.getShared().getFocusManager().findFocusedNode(parent); org.joshy.gfx.event.KeyEvent evt = new org.joshy.gfx.event.KeyEvent( org.joshy.gfx.event.KeyEvent.KeyReleased, org.joshy.gfx.event.KeyEvent.getKeyCodeFromAWT(e.getKeyCode()), node, e.getKeyChar(), e.isShiftDown(), e.isControlDown(), e.isAltDown(), e.isMetaDown()); EventBus.getSystem().publish(evt); }
private void processCompletionKeys(final KeyEvent event) { char keyChar = event.getKeyChar(); int keyCode = event.getKeyCode(); if (keyChar == KeyEvent.VK_ENTER || keyChar == KeyEvent.VK_ESCAPE || keyChar == KeyEvent.VK_TAB || (event.getID() == KeyEvent.KEY_RELEASED && keyCode != KeyEvent.VK_LEFT && keyCode != KeyEvent.VK_RIGHT)) { // ignore } else if (keyChar == ')') { // https://github.com/processing/processing/issues/2741 hideSuggestion(); } else if (keyChar == '.') { if (JavaMode.codeCompletionsEnabled) { Messages.log( "[KeyEvent]" + KeyEvent.getKeyText(event.getKeyCode()) + " |Prediction started"); fetchPhrase(); } } else if (keyChar == ' ') { // Trigger on Ctrl-Space if (!Platform.isMacOS() && JavaMode.codeCompletionsEnabled && (event.isControlDown() || event.isMetaDown())) { // Provide completions only if it's enabled if (JavaMode.codeCompletionsEnabled) { // Removed for https://github.com/processing/processing/issues/3847 // try { // getDocument().remove(getCaretPosition() - 1, 1); // Remove the typed space Messages.log("[KeyEvent]" + event.getKeyChar() + " |Prediction started"); fetchPhrase(); // } catch (BadLocationException e) { // e.printStackTrace(); // } } } else { hideSuggestion(); // hide on spacebar } } else { if (JavaMode.codeCompletionsEnabled) { prepareSuggestions(event); } } }
private void processKey(KeyEvent e) // handles termination, help, and game-play keys { int keyCode = e.getKeyCode(); // termination keys // listen for esc, q, end, ctrl-c on the canvas to // allow a convenient exit from the full screen configuration if ((keyCode == KeyEvent.VK_ESCAPE) || (keyCode == KeyEvent.VK_Q) || (keyCode == KeyEvent.VK_END) || ((keyCode == KeyEvent.VK_C) && e.isControlDown())) running = false; // help controls if (keyCode == KeyEvent.VK_H) { if (showHelp) { // help being shown showHelp = false; // switch off isPaused = false; } else { // help not being shown showHelp = true; // show it isPaused = true; // isPaused may already be true } } // game-play keys if (!isPaused && !gameOver) { // move the sprite and ribbons based on the arrow key pressed if (keyCode == KeyEvent.VK_LEFT) { jack.moveLeft(); bricksMan.moveRight(); // bricks and ribbons move the other way ribsMan.moveRight(); } else if (keyCode == KeyEvent.VK_RIGHT) { jack.moveRight(); bricksMan.moveLeft(); ribsMan.moveLeft(); } else if (keyCode == KeyEvent.VK_UP) jack.jump(); // jumping has no effect on the bricks/ribbons else if (keyCode == KeyEvent.VK_DOWN) { jack.stayStill(); bricksMan.stayStill(); ribsMan.stayStill(); } } } // end of processKey()
@Override protected void processKeyEvent(KeyEvent evt) { if (evt.getID() == KeyEvent.KEY_PRESSED) { ActionContext ac = VFSBrowser.getActionContext(); int row = parentDirectories.getSelectedIndex(); switch (evt.getKeyCode()) { case KeyEvent.VK_DOWN: evt.consume(); if (row < parentDirectories.getSize().height - 1) parentDirectories.setSelectedIndex(++row); break; case KeyEvent.VK_LEFT: if ((evt.getModifiers() & InputEvent.ALT_MASK) > 0) { evt.consume(); browser.previousDirectory(); } else super.processEvent(evt); break; case KeyEvent.VK_RIGHT: if ((evt.getModifiers() & InputEvent.ALT_MASK) > 0) { evt.consume(); browser.nextDirectory(); } else super.processEvent(evt); break; case KeyEvent.VK_TAB: evt.consume(); if ((evt.getModifiers() & InputEvent.SHIFT_MASK) > 0) browser.focusOnDefaultComponent(); else table.requestFocus(); break; case KeyEvent.VK_UP: evt.consume(); if (row > 0) { parentDirectories.setSelectedIndex(--row); } break; case KeyEvent.VK_BACK_SPACE: evt.consume(); EditAction up = ac.getAction("vfs.browser.up"); ac.invokeAction(evt, up); break; case KeyEvent.VK_F5: evt.consume(); EditAction reload = ac.getAction("vfs.browser.reload"); ac.invokeAction(evt, reload); break; case KeyEvent.VK_ENTER: evt.consume(); if (row != -1) { // basically the same handling as in ParentMouseHandler#mouseReleased Object obj = parentDirectories.getModel().getElementAt(row); if (obj instanceof VFSFile) { VFSFile dirEntry = (VFSFile) obj; browser.setDirectory(dirEntry.getPath()); if (browser.getMode() == VFSBrowser.BROWSER) focusOnFileView(); } } break; /* These actions don't work because they look at the EntryTable for the current selected * item. We need actions that look at the parentDirectoryList item instead. * case KeyEvent.VK_DELETE: evt.consume(); ea = ac.getAction("vfs.browser.delete"); ac.invokeAction(evt, ea); break; case KeyEvent.CTRL_MASK | KeyEvent.VK_N: evt.consume(); ea = ac.getAction("vfs.browser.new-file"); ac.invokeAction(evt, ea); break; case KeyEvent.VK_INSERT: evt.consume(); ea = ac.getAction("vfs.browser.new-directory"); ac.invokeAction(evt, ea); break; */ } } else if (evt.getID() == KeyEvent.KEY_TYPED) { if (evt.isControlDown() || evt.isAltDown() || evt.isMetaDown()) { evt.consume(); return; } switch (evt.getKeyChar()) { case '~': evt.consume(); if (browser.getMode() == VFSBrowser.BROWSER) browser.setDirectory(System.getProperty("user.home")); break; case '/': evt.consume(); if (browser.getMode() == VFSBrowser.BROWSER) browser.rootDirectory(); break; case '-': evt.consume(); if (browser.getMode() == VFSBrowser.BROWSER) { browser.setDirectory(browser.getView().getBuffer().getDirectory()); } break; } } if (!evt.isConsumed()) super.processKeyEvent(evt); }
private boolean isControl(KeyEvent e) { return Character.isISOControl(e.getKeyChar()) || (e.isAltDown() || e.isAltGraphDown() || e.isControlDown() || e.isMetaDown()); }