/** This method cannot be called directly. */ public void keyTyped(KeyEvent e) { int keyCode = e.getKeyCode(); System.out.println(keyCode); switch (keyCode) { case KeyEvent.VK_W: // handle up System.out.println("up?"); break; case KeyEvent.VK_DOWN: // handle down break; case KeyEvent.VK_LEFT: // handle left break; case KeyEvent.VK_RIGHT: // handle right break; } System.out.println(e.getKeyChar()); if (e.getKeyChar() == KeyEvent.VK_UP) { System.out.println("up arrow pressed"); } synchronized (keyLock) { keysTyped.addFirst(e.getKeyChar()); } }
/** * Method declaration * * @param k */ public void keyTyped(KeyEvent k) { if (k.getKeyChar() == '\n' && k.isControlDown()) { k.consume(); execute(); } }
/** Handles the event when the key is pressed */ public void processKeyEvent(KeyEvent e) { int keyCode = e.getKeyCode(); if (e.getID() == KeyEvent.KEY_PRESSED) { if (keyCode == KeyEvent.VK_Z) lockZoom(); else if (keyCode == KeyEvent.VK_T) fixElTimePointer(currTime); } else super.processKeyEvent(e); }
public void keyPressed(KeyEvent ke) { if (ke.getKeyCode() == ke.VK_TAB) { int x = ((JTable) ke.getSource()).getSelectedColumn(); int y = ((JTable) ke.getSource()).getSelectedRow(); int maxX = ((JTable) ke.getSource()).getColumnCount(); int maxY = ((JTable) ke.getSource()).getRowCount(); TableModel tm = ((JTable) ke.getSource()).getModel(); if (x == maxX - 1 && y == maxY - 1) { ((DefaultTableModel) tm).addRow(new Object[maxX]); } } }
static void handleKeyTyped(KeyEvent e) { if (e.getKeyChar() == ' ') { currentSequenceNumDisplay++; scribbles = Collections.synchronizedList(new ArrayList<DrawObject>()); currentScribbleNum = 0; } drawArea.repaint(); }
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()
public void keyTyped(KeyEvent e) { char keyChar = e.getKeyChar(); int flags = e.getModifiers(); if (IJ.debugMode) IJ.log( "keyTyped: char=\"" + keyChar + "\" (" + (int) keyChar + "), flags= " + Integer.toHexString(flags) + " (" + KeyEvent.getKeyModifiersText(flags) + ")"); if (keyChar == '\\' || keyChar == 171 || keyChar == 223) { if (((flags & Event.ALT_MASK) != 0)) doCommand("Animation Options..."); else doCommand("Start Animation [\\]"); } }
/** This method cannot be called directly. */ public void keyPressed(KeyEvent e) { int keyCode = e.getKeyCode(); System.out.println("pressed: " + keyCode); synchronized (keyLock) { keysDown.add(e.getKeyCode()); } if (e.getKeyCode() == KeyEvent.VK_RIGHT) { // Right arrow key code move(MOVE_RIGHT); drawGame(); // rx += 0.1; } else if (e.getKeyCode() == KeyEvent.VK_LEFT) { // Left arrow key code move(MOVE_LEFT); drawGame(); // rx -= 0.1; } else if (e.getKeyCode() == KeyEvent.VK_UP) { // Up arrow key code move(MOVE_UP); drawGame(); // ry += 0.1; } else if (e.getKeyCode() == KeyEvent.VK_DOWN) { // Down arrow key code move(MOVE_DOWN); drawGame(); // ry -= 0.1; } }
public void keyReleased(KeyEvent e) { // #if (mov_0) int key = e.getKeyCode(); if (key == KeyEvent.VK_LEFT) { current_Player.setLeft(false); } if (key == KeyEvent.VK_RIGHT) { current_Player.setRight(false); } if (key == KeyEvent.VK_DOWN) current_Player.setDown(false); if (key == KeyEvent.VK_UP) current_Player.setUp(false); if (key == KeyEvent.VK_SHIFT) current_Player.setSpeed(2); // #endif // #if (mov_1) // @ int key = e.getKeyCode(); // @ if (key == KeyEvent.VK_SPACE && current_Player.getLoad()==1) // current_Player.setLoad(2); // @ if (key == KeyEvent.VK_LEFT) current_Player.setLeft(false); // @ if (key == KeyEvent.VK_RIGHT) current_Player.setRight(false); // @ if (key == KeyEvent.VK_DOWN) current_Player.setDown(false); // @ if (key == KeyEvent.VK_UP) current_Player.setUp(false); // @ if (key == KeyEvent.VK_SHIFT) current_Player.setSpeed(2); // #endif // #if (mov_2) // @ int key = e.getKeyCode(); // @ if (key == KeyEvent.VK_LEFT) current_Player.setLeft(false); // @ if (key == KeyEvent.VK_RIGHT) current_Player.setRight(false); // @ if (key == KeyEvent.VK_DOWN) current_Player.setDown(false); // @ if (key == KeyEvent.VK_UP) current_Player.setUp(false); // @ if (key == KeyEvent.VK_SHIFT) current_Player.setSpeed(2); // #endif // #if (mov_3) // @ int key = e.getKeyCode(); // @ if (key == KeyEvent.VK_SPACE && // current_Player.getLoad()==1){current_Player.setLoad(2);} // @ if (key == KeyEvent.VK_LEFT) current_Player.setLeft(false); // @ if (key == KeyEvent.VK_RIGHT) current_Player.setRight(false); // @ if (key == KeyEvent.VK_DOWN) current_Player.setDown(false); // @ if (key == KeyEvent.VK_UP) current_Player.setUp(false); // @ if (key == KeyEvent.VK_SHIFT) current_Player.setSpeed(2); // #endif // #if (mov_4) // @ int key = e.getKeyCode(); // @ if (key == KeyEvent.VK_SPACE && current_Player.getLoad()==1) // current_Player.setLoad(2); // @ if (key == KeyEvent.VK_LEFT) current_Player.setLeft(false); // @ if (key == KeyEvent.VK_RIGHT) current_Player.setRight(false); // @ if (key == KeyEvent.VK_DOWN) current_Player.setDown(false); // @ if (key == KeyEvent.VK_UP) current_Player.setUp(false); // @ if (key == KeyEvent.VK_SHIFT) current_Player.setSpeed(2); // #endif }
private void displayInfo(KeyEvent e, String keyStatus) { // Method copied from http://java.sun.com/docs/books/tutorial/uiswing/events/keylistener.html // You should only rely on the key char if the event // is a key typed event. int id = e.getID(); String keyString; if (id == KeyEvent.KEY_TYPED) { char c = e.getKeyChar(); keyString = "key character = '" + c + "'"; } else { int keyCode = e.getKeyCode(); keyString = "key code = " + keyCode + " (" + KeyEvent.getKeyText(keyCode) + ")"; } int modifiersEx = e.getModifiersEx(); String modString = "extended modifiers = " + modifiersEx; String tmpString = KeyEvent.getModifiersExText(modifiersEx); if (tmpString.length() > 0) { modString += " (" + tmpString + ")"; } else { modString += " (no extended modifiers)"; } String actionString = "action key? "; if (e.isActionKey()) { actionString += "YES"; } else { actionString += "NO"; } String locationString = "key location: "; int location = e.getKeyLocation(); if (location == KeyEvent.KEY_LOCATION_STANDARD) { locationString += "standard"; } else if (location == KeyEvent.KEY_LOCATION_LEFT) { locationString += "left"; } else if (location == KeyEvent.KEY_LOCATION_RIGHT) { locationString += "right"; } else if (location == KeyEvent.KEY_LOCATION_NUMPAD) { locationString += "numpad"; } else { // (location == KeyEvent.KEY_LOCATION_UNKNOWN) locationString += "unknown"; } // Added: System.out.println("Keypress: " + keyString); }
public void keyPressed(KeyEvent e) { int dx = 0; int dy = 0; if (e.getKeyCode() == KeyEvent.VK_LEFT) { dx = -1; } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) { dx = 1; } else if (e.getKeyCode() == KeyEvent.VK_UP) { dy = -1; } else if (e.getKeyCode() == KeyEvent.VK_DOWN) { dy = 1; } int multiplier = 1; if (e.isShiftDown() && e.isAltDown()) { multiplier = 10; } else if (e.isShiftDown() || e.isAltDown()) { multiplier = 5; } if (dx != 0 || dy != 0) { int size = Math.min( MAX_SIZE, Math.min( getWidth() - imagePadding.left - imagePadding.right, getHeight() - imagePadding.top - imagePadding.bottom)); int offsetX = getWidth() / 2 - size / 2; int offsetY = getHeight() / 2 - size / 2; mouseListener.mousePressed( new MouseEvent( ColorPickerPanel.this, MouseEvent.MOUSE_PRESSED, System.currentTimeMillis(), 0, point.x + multiplier * dx + offsetX, point.y + multiplier * dy + offsetY, 1, false)); } }
/** This method cannot be called directly. */ public void keyReleased(KeyEvent e) { keysDown.remove(e.getKeyCode()); }
/** This method cannot be called directly. */ public void keyPressed(KeyEvent e) { keysDown.add(e.getKeyCode()); }
/** This method cannot be called directly. */ public void keyTyped(KeyEvent e) { synchronized (keyLock) { keysTyped.addFirst(e.getKeyChar()); } }
/** This method cannot be called directly. */ public void keyReleased(KeyEvent e) { synchronized (keyLock) { keysDown.remove(e.getKeyCode()); } }
/** * Need this method to detect when the focus may have chance to leave the focus cycle root which * is EmbeddedFrame. Mostly, the code here is copied from * DefaultKeyboardFocusManager.processKeyEvent with some minor modifications. */ public boolean dispatchKeyEvent(KeyEvent e) { // We can't guarantee that this is called on the same AppContext as EmbeddedFrame // belongs to. That's why we can't use public methods to find current focus cycle // root. Instead, we access KFM's private field directly. if (currentCycleRoot == null) { currentCycleRoot = (Field) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { try { Field unaccessibleRoot = KeyboardFocusManager.class.getDeclaredField("currentFocusCycleRoot"); if (unaccessibleRoot != null) { unaccessibleRoot.setAccessible(true); } return unaccessibleRoot; } catch (NoSuchFieldException e1) { assert false; } catch (SecurityException e2) { assert false; } return null; } }); } Container currentRoot = null; if (currentCycleRoot != null) { try { // The field is static, so we can pass null to Field.get() as the argument. currentRoot = (Container) currentCycleRoot.get(null); } catch (IllegalAccessException e3) { // This is impossible: currentCycleRoot would be null if setAccessible failed. assert false; } } // if we are not in EmbeddedFrame's cycle, we should not try to leave. if (this != currentRoot) { return false; } // KEY_TYPED events cannot be focus traversal keys if (e.getID() == KeyEvent.KEY_TYPED) { return false; } if (!getFocusTraversalKeysEnabled() || e.isConsumed()) { return false; } AWTKeyStroke stroke = AWTKeyStroke.getAWTKeyStrokeForEvent(e); Set toTest; Component currentFocused = e.getComponent(); Component last = getFocusTraversalPolicy().getLastComponent(this); toTest = getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS); if (toTest.contains(stroke) && (currentFocused == last || last == null)) { if (traverseOut(FORWARD)) { e.consume(); return true; } } Component first = getFocusTraversalPolicy().getFirstComponent(this); toTest = getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS); if (toTest.contains(stroke) && (currentFocused == first || first == null)) { if (traverseOut(BACKWARD)) { e.consume(); return true; } } return false; }
public void keyPressed(KeyEvent e) { // #if (mov_0) int key = e.getKeyCode(); if (key == KeyEvent.VK_LEFT) { current_Player.setLeft(true); } if (key == KeyEvent.VK_RIGHT) { current_Player.setRight(true); } if (key == KeyEvent.VK_DOWN) current_Player.setDown(true); if (key == KeyEvent.VK_UP) current_Player.setUp(true); if (key == KeyEvent.VK_SHIFT) current_Player.setSpeed(3); if (key == KeyEvent.VK_ENTER) if (current_Player.getSch().isIsActive() == false) changepl(); if (key == KeyEvent.VK_F1) ls.createNewPlayer(); // #if(tar) // @ if (key == KeyEvent.VK_Q){ // @ // current_Player.setRocket(true); // @ // sch = new Schuss((int)current_Player.getX(),(int)current_Player.getY()); // @ // current_Player.setBp(0); // @ } // #endif // #elif (mov_1) // @ int key = e.getKeyCode(); // @ if (key == KeyEvent.VK_LEFT){ // @ current_Player.setLeft(true); // @ } // @ if (key == KeyEvent.VK_RIGHT){ // @ current_Player.setRight(true); // @ } // @ if (key == KeyEvent.VK_SPACE && current_Player.getLoad() < 2){ // @ current_Player.setBp(current_Player.getBp()+5); // @ current_Player.setLoad(1); // @ } // @ if (key == KeyEvent.VK_DOWN) current_Player.setDown(true); // @ if (key == KeyEvent.VK_UP) current_Player.setUp(true); // @ if (key == KeyEvent.VK_SHIFT) current_Player.setSpeed(3); // @ if (key == KeyEvent.VK_ENTER) if (current_Player.getSch().isIsActive()==false) // changepl(); // @ if (key == KeyEvent.VK_F1) ls.createNewPlayer(); // #elif (mov_2) // @ int key = e.getKeyCode(); // @ if (key == KeyEvent.VK_LEFT) current_Player.setLeft(true); // @ if (key == KeyEvent.VK_RIGHT) current_Player.setRight(true); // @ if (key == KeyEvent.VK_DOWN) current_Player.setDown(true); // @ if (key == KeyEvent.VK_UP) current_Player.setUp(true); // @ if (key == KeyEvent.VK_SHIFT) current_Player.setSpeed(3); // @ if (key == KeyEvent.VK_ENTER) if (current_Player.getSch().isIsActive()==false) // changepl(); // @ if (key == KeyEvent.VK_F1) ls.createNewPlayer(); // #elif (mov_3) // @ int key = e.getKeyCode(); // @ if (key == KeyEvent.VK_LEFT){ // @ current_Player.setLeft(true); // @ } // @ if (key == KeyEvent.VK_RIGHT){ // @ current_Player.setRight(true); // @ } // @ if (key == KeyEvent.VK_SPACE){ // @ current_Player.setBp(current_Player.getBp()+5); // @ current_Player.setLoad(1); // @ //current_Player.setSpeed(5); // @ } // @ if (key == KeyEvent.VK_DOWN) current_Player.setDown(true); // @ if (key == KeyEvent.VK_UP) current_Player.setUp(true); // @ if (key == KeyEvent.VK_SHIFT) current_Player.setSpeed(3); // @ if (key == KeyEvent.VK_ENTER) if (current_Player.getSch().isIsActive()==false) // changepl(); // @ if (key == KeyEvent.VK_F1) ls.createNewPlayer(); // #elif (mov_4) // @ int key = e.getKeyCode(); // @ if (key == KeyEvent.VK_LEFT){ // @ current_Player.setLeft(true); // @ } // @ if (key == KeyEvent.VK_RIGHT){ // @ current_Player.setRight(true); // @ } // @ if (key == KeyEvent.VK_SPACE && current_Player.getLoad() < 2){ // @ current_Player.setBp(current_Player.getBp()+5); // @ current_Player.setLoad(1); // @ } // @ if (key == KeyEvent.VK_DOWN) current_Player.setDown(true); // @ if (key == KeyEvent.VK_UP) current_Player.setUp(true); // @ if (key == KeyEvent.VK_SHIFT) current_Player.setSpeed(3); // @ if (key == KeyEvent.VK_ENTER) if (current_Player.getSch().isIsActive()==false) // changepl(); // @ if (key == KeyEvent.VK_F1) ls.createNewPlayer(); // #endif // neu beginn if (key == KeyEvent.VK_Q) { // #if (tar) // @ current_Player.setRocket(true); // @ sch = new Schuss((int)current_Player.getX(),(int)current_Player.getY()); // @ current_Player.setBp(0); // #endif } // neu ende }
@Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == 67) // C { if (captureWindow) { this.openCaptureWindow(); } else { this.captureImage(); } } else if (e.getKeyCode() == 27) // Escape { System.out.println("Escape pressed, exiting"); System.exit(0); } else if (e.getKeyCode() == 84) // t { // Testing purpose for (int i = 0; i < images.size(); i++) { System.out.println("image " + i + ", used? " + images_used.contains((Integer) i)); } } else if (e.getKeyCode() == 89) // y { // Testing purpose System.out.println("getRandomImageNum() = " + getRandomImageNum()); } else if (e.getKeyCode() == 73) // i { // Testing purpose System.out.println("LAST ADDED"); for (int i = 0; i < images_lastadded.size(); i++) { System.out.println( i + " - image " + images_lastadded.get(i) + ", used? " + images_used.contains((Integer) images_lastadded.get(i))); } } else if (e.getKeyCode() == 85) // u { // Testing purpose for (int i = 0; i < imagepanels.length; i++) { for (int j = 0; j < imagepanels[i].imagenum_now.length; j++) { for (int j2 = 0; j2 < imagepanels[i].imagenum_now[j].length; j2++) { String print1; if (imagepanels[i].imagenum_now[j][j2] < 10) print1 = " " + imagepanels[i].imagenum_now[j][j2]; else if (imagepanels[i].imagenum_now[j][j2] < 100) print1 = " " + imagepanels[i].imagenum_now[j][j2]; else print1 = "" + imagepanels[i].imagenum_now[j][j2]; String print2; if (imagepanels[i].imagenum_next[j][j2] < 10) print2 = " " + imagepanels[i].imagenum_next[j][j2]; else if (imagepanels[i].imagenum_next[j][j2] < 100) print2 = " " + imagepanels[i].imagenum_next[j][j2]; else print2 = "" + imagepanels[i].imagenum_next[j][j2]; System.out.println( "imagepanels[" + i + "]." + "imagenum_now[" + j + "][" + j2 + "] = " + print1 + ", next = " + print2); } } } } else { displayInfo(e, "KEY TYPED: "); } }
public void keyPressed(KeyEvent e) { // if (e.isConsumed()) return; int keyCode = e.getKeyCode(); IJ.setKeyDown(keyCode); hotkey = false; if (keyCode == KeyEvent.VK_CONTROL || keyCode == KeyEvent.VK_SHIFT) return; char keyChar = e.getKeyChar(); int flags = e.getModifiers(); if (IJ.debugMode) IJ.log( "keyPressed: code=" + keyCode + " (" + KeyEvent.getKeyText(keyCode) + "), char=\"" + keyChar + "\" (" + (int) keyChar + "), flags=" + KeyEvent.getKeyModifiersText(flags)); boolean shift = (flags & KeyEvent.SHIFT_MASK) != 0; boolean control = (flags & KeyEvent.CTRL_MASK) != 0; boolean alt = (flags & KeyEvent.ALT_MASK) != 0; boolean meta = (flags & KeyEvent.META_MASK) != 0; String cmd = null; ImagePlus imp = WindowManager.getCurrentImage(); boolean isStack = (imp != null) && (imp.getStackSize() > 1); if (imp != null && !control && ((keyChar >= 32 && keyChar <= 255) || keyChar == '\b' || keyChar == '\n')) { Roi roi = imp.getRoi(); if (roi instanceof TextRoi) { if ((flags & KeyEvent.META_MASK) != 0 && IJ.isMacOSX()) return; if (alt) { switch (keyChar) { case 'u': case 'm': keyChar = IJ.micronSymbol; break; case 'A': keyChar = IJ.angstromSymbol; break; default: } } ((TextRoi) roi).addChar(keyChar); return; } } // Handle one character macro shortcuts if (!control && !meta) { Hashtable macroShortcuts = Menus.getMacroShortcuts(); if (macroShortcuts.size() > 0) { if (shift) cmd = (String) macroShortcuts.get(new Integer(keyCode + 200)); else cmd = (String) macroShortcuts.get(new Integer(keyCode)); if (cmd != null) { // MacroInstaller.runMacroCommand(cmd); commandName = cmd; MacroInstaller.runMacroShortcut(cmd); return; } } } if ((!Prefs.requireControlKey || control || meta) && keyChar != '+') { Hashtable shortcuts = Menus.getShortcuts(); if (shift) cmd = (String) shortcuts.get(new Integer(keyCode + 200)); else cmd = (String) shortcuts.get(new Integer(keyCode)); } if (cmd == null) { switch (keyChar) { case '<': case ',': if (isStack) cmd = "Previous Slice [<]"; break; case '>': case '.': case ';': if (isStack) cmd = "Next Slice [>]"; break; case '+': case '=': cmd = "In [+]"; break; case '-': cmd = "Out [-]"; break; case '/': cmd = "Reslice [/]..."; break; default: } } if (cmd == null) { switch (keyCode) { case KeyEvent.VK_TAB: WindowManager.putBehind(); return; case KeyEvent.VK_BACK_SPACE: // delete if (deleteOverlayRoi(imp)) return; cmd = "Clear"; hotkey = true; break; // case KeyEvent.VK_BACK_SLASH: cmd=IJ.altKeyDown()?"Animation Options...":"Start // Animation"; break; case KeyEvent.VK_EQUALS: cmd = "In [+]"; break; case KeyEvent.VK_MINUS: cmd = "Out [-]"; break; case KeyEvent.VK_SLASH: case 0xbf: cmd = "Reslice [/]..."; break; case KeyEvent.VK_COMMA: case 0xbc: if (isStack) cmd = "Previous Slice [<]"; break; case KeyEvent.VK_PERIOD: case 0xbe: if (isStack) cmd = "Next Slice [>]"; break; case KeyEvent.VK_LEFT: case KeyEvent.VK_RIGHT: case KeyEvent.VK_UP: case KeyEvent.VK_DOWN: // arrow keys if (imp == null) return; Roi roi = imp.getRoi(); if (IJ.shiftKeyDown() && imp == Orthogonal_Views.getImage()) return; boolean stackKey = imp.getStackSize() > 1 && (roi == null || IJ.shiftKeyDown()); boolean zoomKey = roi == null || IJ.shiftKeyDown() || IJ.controlKeyDown(); if (stackKey && keyCode == KeyEvent.VK_RIGHT) cmd = "Next Slice [>]"; else if (stackKey && keyCode == KeyEvent.VK_LEFT) cmd = "Previous Slice [<]"; else if (zoomKey && keyCode == KeyEvent.VK_DOWN && !ignoreArrowKeys(imp) && Toolbar.getToolId() < Toolbar.SPARE6) cmd = "Out [-]"; else if (zoomKey && keyCode == KeyEvent.VK_UP && !ignoreArrowKeys(imp) && Toolbar.getToolId() < Toolbar.SPARE6) cmd = "In [+]"; else if (roi != null) { if ((flags & KeyEvent.ALT_MASK) != 0) roi.nudgeCorner(keyCode); else roi.nudge(keyCode); return; } break; case KeyEvent.VK_ESCAPE: abortPluginOrMacro(imp); return; case KeyEvent.VK_ENTER: WindowManager.toFront(this); return; default: break; } } if (cmd != null && !cmd.equals("")) { commandName = cmd; if (cmd.equals("Fill") || cmd.equals("Draw")) hotkey = true; if (cmd.charAt(0) == MacroInstaller.commandPrefix) MacroInstaller.runMacroShortcut(cmd); else { doCommand(cmd); keyPressedTime = System.currentTimeMillis(); lastKeyCommand = cmd; } } }
/** This method cannot be called directly. */ public void keyPressed(KeyEvent e) { synchronized (keyLock) { keysDown.add(e.getKeyCode()); } }
public void keyTyped(KeyEvent e) { char key = e.getKeyChar(); if (key == '\n') atc_obj.getInputhandler().processCommand(); else atc_obj.getInputhandler().processKey(key); }
public void keyReleased(KeyEvent e) { IJ.setKeyUp(e.getKeyCode()); }
@Override public void keyPressed(KeyEvent arg0) { if (arg0.getKeyCode() == 67) // C { // Are we allowed to capture a new image? if (framenr - lastcapture_framenr > number_of_frames_betweencaptures) { captureImage(); cw.setVisible(false); if (timer != null) timer.cancel(); cwText.setText(""); // Empty text lastcapture_framenr = framenr; cwTimer.cancel(); if (number_of_second_showcapturetext > 0) { cwText.setText("Bildet ble lagret ..."); TimerTask task = new TimerTask() { @Override public void run() { EventQueue.invokeLater( new Runnable() { public void run() { cwText.setText(""); // Empty text } }); } }; timer = new Timer(); timer.schedule(task, (int) (number_of_second_showcapturetext * 1000)); } } else { // Console debug: // System.out.println("At framenr " + framenr + ", " + (framenr-lastcapture_framenr) + // "frames has passed, should be " +number_of_frames_betweencaptures); // System.out.println("You must wait an other "+ // // (int)Math.ceil(((double)number_of_frames_betweencaptures-(double)(framenr-lastcapture_framenr))/fps) + // " seconds"); TimerTask task = new TimerTask() { boolean finished = false; @Override public void run() { EventQueue.invokeLater( new Runnable() { public void run() { if (!finished) { if ((int) Math.ceil( ((double) number_of_frames_betweencaptures - (double) (framenr - lastcapture_framenr)) / fps) > 0) { cwText.setText( "Du må vente " + (int) Math.ceil( ((double) number_of_frames_betweencaptures - (double) (framenr - lastcapture_framenr)) / fps) + " sekunder før nytt bilde"); } else { finished = true; cwText.setText("Du kan nå ta nytt bilde"); } } } }); } }; timer = new Timer(); timer.schedule(task, 0, (1000 / fps)); // Update for every frame } } else if (arg0.getKeyCode() == 27) // Escape { System.out.println("Escape pressed, exiting"); System.exit(0); } }