Java Code Examples for java.awt.event.KeyEvent#VK_A
The following examples show how to use
java.awt.event.KeyEvent#VK_A .
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: DefaultInteractionEventHandler.java From constellation with Apache License 2.0 | 6 votes |
/** * Respond to a key press event on the graph. This will respond to keys that * interact directly with the graph's visuals, such as W,A,S,D to pan. Most * key presses in CONSTELLATION, for example Ctrl+A, will be picked up by * the netbeans framework and cause plugins to be executed. * <p> * This is called continually whenever a key is held down (at the key repeat * rate of the operating system). * * @param event The KeyEvent related to the key press. */ @Override public void keyPressed(final KeyEvent event) { final int keyCode = event.getKeyCode(); // Avoid the control key so we don't interfere with ^S for save, for example. final boolean isCtrl = event.isControlDown(); final boolean isShift = event.isShiftDown(); if (keyCode == KeyEvent.VK_PAGE_UP || keyCode == KeyEvent.VK_PAGE_DOWN || (!isCtrl && (keyCode == KeyEvent.VK_A || keyCode == KeyEvent.VK_D || keyCode == KeyEvent.VK_S || keyCode == KeyEvent.VK_W))) { queue.add(wg -> { if (wg != null) { final Camera camera = new Camera(VisualGraphUtilities.getCamera(wg)); if (keyCode == KeyEvent.VK_PAGE_UP) { CameraUtilities.changeMixRatio(camera, true, isCtrl); eventState.addEventName(MIX_ACTION_NAME); } else if (keyCode == KeyEvent.VK_PAGE_DOWN) { CameraUtilities.changeMixRatio(camera, false, isCtrl); eventState.addEventName(MIX_ACTION_NAME); } else if (keyCode == KeyEvent.VK_A) { CameraUtilities.pan(camera, -0.5f * (isShift ? 10 : 1), 0); eventState.addEventName(PAN_ACTION_NAME); } else if (keyCode == KeyEvent.VK_D) { CameraUtilities.pan(camera, 0.5f * (isShift ? 10 : 1), 0); eventState.addEventName(PAN_ACTION_NAME); } else if (keyCode == KeyEvent.VK_S) { CameraUtilities.pan(camera, 0, -0.5f * (isShift ? 10 : 1)); eventState.addEventName(PAN_ACTION_NAME); } else if (keyCode == KeyEvent.VK_W) { CameraUtilities.pan(camera, 0, 0.5f * (isShift ? 10 : 1)); eventState.addEventName(PAN_ACTION_NAME); } VisualGraphUtilities.setCamera(wg, camera); scheduleCameraChangeOperation(); } return STANDARD_DELAY; }); } }
Example 2
Source File: KeyManager.java From New-Beginner-Java-Game-Programming-Src with Creative Commons Zero v1.0 Universal | 6 votes |
public void tick(){ for(int i = 0;i < keys.length;i++){ if(cantPress[i] && !keys[i]){ cantPress[i] = false; }else if(justPressed[i]){ cantPress[i] = true; justPressed[i] = false; } if(!cantPress[i] && keys[i]){ justPressed[i] = true; } } up = keys[KeyEvent.VK_W]; down = keys[KeyEvent.VK_S]; left = keys[KeyEvent.VK_A]; right = keys[KeyEvent.VK_D]; aUp = keys[KeyEvent.VK_UP]; aDown = keys[KeyEvent.VK_DOWN]; aLeft = keys[KeyEvent.VK_LEFT]; aRight = keys[KeyEvent.VK_RIGHT]; }
Example 3
Source File: Plane.java From JavaGame with MIT License | 6 votes |
/** * �ɿ����̵ķ��� * * @param e * �����¼� */ public void keyReleased(KeyEvent e) { switch (e.getKeyCode()) { case KeyEvent.VK_A: left = false; break; case KeyEvent.VK_S: down = false; break; case KeyEvent.VK_D: right = false; break; case KeyEvent.VK_W: up = false; break; case KeyEvent.VK_J:// ���ӵ� fire = false; break; } }
Example 4
Source File: Plane.java From JavaGame with MIT License | 6 votes |
/** * ���¼��̵ķ��� * * @param e */ public void keyPressed(KeyEvent e) { switch (e.getKeyCode()) { case KeyEvent.VK_A: left = true; break; case KeyEvent.VK_S: down = true; break; case KeyEvent.VK_D: right = true; break; case KeyEvent.VK_W: up = true; break; case KeyEvent.VK_J:// ���ӵ� superFire = false; fire = true; break; case KeyEvent.VK_SPACE:// �������ӵ� fire = false; superFire = true; break; } }
Example 5
Source File: AbstractSpotModule.java From orbit-image-analysis with GNU General Public License v3.0 | 6 votes |
public void keyPressed(KeyEvent e) { int keyNum = -1; try { keyNum = Integer.parseInt(e.getKeyChar() + "") + getClassNumOffset(); // number pressed? (if so, substract -1 because we count from 0) } catch (Exception ignored) { } if (keyNum >= 0) { setClass(keyNum, e); } else { // del pressed? -> remove selected items if (e.getKeyCode() == KeyEvent.VK_DELETE) { removeSpots(); OrbitImageAnalysis.getInstance().getIFrame().getRecognitionFrame().repaint(); } else if (e.getKeyCode() == KeyEvent.VK_BACK_SPACE) { unsetClass(); OrbitImageAnalysis.getInstance().getIFrame().getRecognitionFrame().repaint(); } else if (e.getKeyCode() == KeyEvent.VK_A) { acceptClass(e); OrbitImageAnalysis.getInstance().getIFrame().getRecognitionFrame().repaint(); } } }
Example 6
Source File: deadKeyMacOSX.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override public void keyPressed(KeyEvent e) { int keyCode = e.getKeyCode(); char keyChar = e.getKeyChar(); switch (state) { case 0: if (keyCode != KeyEvent.VK_ALT) { throw new RuntimeException("Alt is not pressed."); } state++; break; case 1: if (keyCode != KeyEvent.VK_DEAD_ACUTE) { throw new RuntimeException("Dead ACUTE is not pressed."); } if (keyChar != 0xB4) { throw new RuntimeException("Pressed char is not dead acute."); } state++; break; case 2: if (keyCode != KeyEvent.VK_A) { throw new RuntimeException("A is not pressed."); } if (keyChar != 0xE1) { throw new RuntimeException("A char does not have ACCUTE accent"); } state++; break; default: throw new RuntimeException("Excessive keyPressed event."); } }
Example 7
Source File: ComponentCreatorManager.java From PIPE with MIT License | 5 votes |
public ComponentCreatorManager(UndoableEditListener undoListener, PipeApplicationModel applicationModel, PipeApplicationController applicationController) { placeAction = new PlaceAction(applicationModel); transAction = new ImmediateTransitionAction(applicationModel); timedtransAction = new TimedTransitionAction(applicationModel); annotationAction = new AnnotationAction(applicationModel); inhibarcAction = new ArcAction("Inhibitor Arc", "Add an inhibitor arc (alt-h)", KeyEvent.VK_H, InputEvent.ALT_DOWN_MASK, new InhibitorSourceVisitor(), new InhibitorCreator(), applicationModel, applicationController, new InhibitorArcHead()); arcAction = new ArcAction("Arc", "Add an arc (alt-a)", KeyEvent.VK_A, InputEvent.ALT_DOWN_MASK, new NormalArcSourceVisitor(), new NormalCreator(applicationController), applicationModel, applicationController, new NormalHead()); rateParameterAction = new SpecifyRateParameterAction(applicationController); placeAction.addUndoableEditListener(undoListener); transAction.addUndoableEditListener(undoListener); timedtransAction.addUndoableEditListener(undoListener); arcAction.addUndoableEditListener(undoListener); inhibarcAction.addUndoableEditListener(undoListener); annotationAction.addUndoableEditListener(undoListener); rateParameterAction.addUndoableEditListener(undoListener); }
Example 8
Source File: NativeDisplayKeyListener.java From salty-engine with Apache License 2.0 | 5 votes |
@Override public void keyPressed(final KeyEvent e) { if (keyboardHandler != null) { keyboardHandler.keyPressed(e); } currentKey = e.getKeyChar(); if (e.getKeyCode() == KeyEvent.VK_W || e.getKeyCode() == KeyEvent.VK_UP) { inputUp = true; } if (e.getKeyCode() == KeyEvent.VK_S || e.getKeyCode() == KeyEvent.VK_DOWN) { inputDown = true; } if (e.getKeyCode() == KeyEvent.VK_A || e.getKeyCode() == KeyEvent.VK_LEFT) { inputLeft = true; } if (e.getKeyCode() == KeyEvent.VK_D || e.getKeyCode() == KeyEvent.VK_RIGHT) { inputRight = true; } if (SceneManager.getCurrentScene().getUI() != null) { SceneManager.getCurrentScene().getUI().keyPressed(e); } Input.keyboardInput.handleKeyPressed(e); updateInputStates(); Input.lastInput = e; Input.getKeyboardHandlers().forEach(keyboardInputHandler -> keyboardInputHandler.keyPressed(e)); }
Example 9
Source File: KeyboardLayoutUtil.java From consulo with Apache License 2.0 | 5 votes |
public static void storeAsciiForChar(@Nonnull KeyEvent e) { int id = e.getID(); if (id != KeyEvent.KEY_PRESSED) return; int mods = e.getModifiers(); int code = e.getKeyCode(); char aChar = e.getKeyChar(); if ((mods & ~InputEvent.SHIFT_MASK & ~InputEvent.SHIFT_DOWN_MASK) != 0) return; if (code < KeyEvent.VK_A || code > KeyEvent.VK_Z) return; if (aChar == KeyEvent.CHAR_UNDEFINED) return; if ('a' <= aChar && aChar <= 'z' || 'A' <= aChar && aChar <= 'Z') return; if (ourLLtoASCII.containsKey(aChar)) return; ourLLtoASCII.put(aChar, (char)((int)'a' + (code - KeyEvent.VK_A))); }
Example 10
Source File: OSUtils.java From marathonv5 with Apache License 2.0 | 5 votes |
private static CharSequence keyCharFromKeyCode(int keyCode, String keysFor) { if (keyCode >= KeyEvent.VK_A && keyCode <= KeyEvent.VK_Z) { return "" + (char) (keyCode - KeyEvent.VK_A + 'a'); } KeysMap entry = KeysMap.findMap(keyCode); if (entry != null) { return entry.getKeys(); } if (keyCode <= 0x7F) { return "" + (char) keyCode; } throw new WebDriverException("Unable to find Keys entry for keycode " + keyCode + " for action " + keysFor); }
Example 11
Source File: deadKeyMacOSX.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
@Override public void keyPressed(KeyEvent e) { int keyCode = e.getKeyCode(); char keyChar = e.getKeyChar(); switch (state) { case 0: if (keyCode != KeyEvent.VK_ALT) { throw new RuntimeException("Alt is not pressed."); } state++; break; case 1: if (keyCode != KeyEvent.VK_DEAD_ACUTE) { throw new RuntimeException("Dead ACUTE is not pressed."); } if (keyChar != 0xB4) { throw new RuntimeException("Pressed char is not dead acute."); } state++; break; case 2: if (keyCode != KeyEvent.VK_A) { throw new RuntimeException("A is not pressed."); } if (keyChar != 0xE1) { throw new RuntimeException("A char does not have ACCUTE accent"); } state++; break; default: throw new RuntimeException("Excessive keyPressed event."); } }
Example 12
Source File: BoundingBoxWindow.java From Pixie with MIT License | 5 votes |
/** * Handle the keyboard events when Alt key is pressed. * * @param key the key code */ private void handleAltKey(int key) { switch (key) { case KeyEvent.VK_A: // increase left changeSize(-1, 0, 0, 0); break; case KeyEvent.VK_W: // increase top changeSize(0, -1, 0, 0); break; case KeyEvent.VK_D: // increase right changeSize(0, 0, 1, 0); break; case KeyEvent.VK_S: // increase bottom changeSize(0, 0, 0, 1); break; case KeyEvent.VK_Z: // decrease box changeSize(1, 1, -1, -1); break; case KeyEvent.VK_X: // increase box changeSize(-1, -1, 1, 1); break; default: // do nothing break; } }
Example 13
Source File: java_awt_MenuShortcut.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
protected MenuShortcut getObject() { return new MenuShortcut(KeyEvent.VK_A); }
Example 14
Source File: KeyManager.java From New-Beginner-Java-Game-Programming-Src with Creative Commons Zero v1.0 Universal | 4 votes |
public void tick(){ up = keys[KeyEvent.VK_W]; down = keys[KeyEvent.VK_S]; left = keys[KeyEvent.VK_A]; right = keys[KeyEvent.VK_D]; }
Example 15
Source File: ProjectTree.java From TrakEM2 with GNU General Public License v3.0 | 4 votes |
@Override public void keyPressed(final KeyEvent ke) { super.keyPressed(ke); if (ke.isConsumed()) return; if (!ke.getSource().equals(ProjectTree.this) || !project.isInputEnabled()) { return; } // get the first selected node only TreePath path = getSelectionPath(); if (null == path) return; DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent(); if (null == node) return; final ProjectThing pt = (ProjectThing)node.getUserObject(); if (null == pt) return; // final int flags = ke.getModifiers(); switch (ke.getKeyCode()) { case KeyEvent.VK_PAGE_UP: move(node, -1); ke.consume(); // in any case break; case KeyEvent.VK_PAGE_DOWN: move(node, 1); ke.consume(); // in any case break; case KeyEvent.VK_F2: rename(pt); ke.consume(); break; case KeyEvent.VK_H: if (0 == (flags ^ Event.ALT_MASK)) { pt.setVisible(true); ke.consume(); } else if (0 == flags) { pt.setVisible(false); ke.consume(); } break; case KeyEvent.VK_A: if (0 == flags || (0 == (flags ^ Event.SHIFT_MASK))) { selectInDisplay(pt, 0 == (flags ^ Event.SHIFT_MASK)); ke.consume(); } break; case KeyEvent.VK_3: if (0 == flags) { ini.trakem2.display.Display3D.showAndResetView(pt); ke.consume(); break; } // else, flow: case KeyEvent.VK_1: case KeyEvent.VK_2: case KeyEvent.VK_4: case KeyEvent.VK_5: case KeyEvent.VK_6: case KeyEvent.VK_7: case KeyEvent.VK_8: case KeyEvent.VK_9: // run a plugin, if any if (pt.getObject() instanceof Displayable && null != Utils.launchTPlugIn(ke, "Project Tree", project, (Displayable)pt.getObject())) { ke.consume(); } break; } ke.consume(); }
Example 16
Source File: java_awt_MenuShortcut.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
protected MenuShortcut getObject() { return new MenuShortcut(KeyEvent.VK_A); }
Example 17
Source File: java_awt_MenuShortcut.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
protected MenuShortcut getObject() { return new MenuShortcut(KeyEvent.VK_A); }
Example 18
Source File: ConstructionWizard.java From mars-sim with GNU General Public License v3.0 | 4 votes |
/** * Sets the new x and y location and facing of the site * @param s * @param c */ public void processKeyPress(ConstructionSite s, int c) { int facing = (int) s.getFacing(); double x = s.getXLocation(); double y = s.getYLocation(); if (c == KeyEvent.VK_UP // 38 || c == KeyEvent.VK_KP_UP || c == KeyEvent.VK_W || c == KeyEvent.VK_NUMPAD8) { upKeyPressed = true; } else if(c == KeyEvent.VK_DOWN // 40 || c == KeyEvent.VK_KP_DOWN || c == KeyEvent.VK_S || c == KeyEvent.VK_NUMPAD2) { downKeyPressed = true; } else if(c == KeyEvent.VK_LEFT // 37 || c == KeyEvent.VK_KP_LEFT || c == KeyEvent.VK_A || c == KeyEvent.VK_NUMPAD4) { leftKeyPressed = true; } else if(c == KeyEvent.VK_RIGHT // 39 || c == KeyEvent.VK_KP_RIGHT || c == KeyEvent.VK_D || c == KeyEvent.VK_NUMPAD6) { rightKeyPressed = true; } else if(c == KeyEvent.VK_R || c == KeyEvent.VK_F) { turnKeyPressed = true; } double w0 = s.getWidth(); double l0 = s.getLength(); double f0 = s.getFacing(); BoundedObject b0 = null; if (upKeyPressed) { b0 = new BoundedObject(s.getXLocation(), s.getYLocation() + 3, w0, l0, f0); if (!isCollided(b0)) s.setYLocation(y + 1); } if (downKeyPressed) { b0 = new BoundedObject(s.getXLocation(), s.getYLocation() - 3, w0, l0, f0); if (!isCollided(b0)) s.setYLocation(y - 1); } if (leftKeyPressed) { b0 = new BoundedObject(s.getXLocation() + 3, s.getYLocation(), w0, l0, f0); if (!isCollided(b0)) s.setXLocation(x + 1); } if (rightKeyPressed) { b0 = new BoundedObject(s.getXLocation() - 3, s.getYLocation(), w0, l0, f0); if (!isCollided(b0)) s.setXLocation(x - 1); } if (turnKeyPressed) { facing = facing + 45; if (facing >= 360) facing = facing - 360; b0 = new BoundedObject(s.getXLocation(), s.getYLocation(), w0, l0, facing); if (!isCollided(b0)) { s.setFacing(facing); } } }
Example 19
Source File: KeyManager.java From New-Beginner-Java-Game-Programming-Src with Creative Commons Zero v1.0 Universal | 4 votes |
public void tick(){ up = keys[KeyEvent.VK_W]; down = keys[KeyEvent.VK_S]; left = keys[KeyEvent.VK_A]; right = keys[KeyEvent.VK_D]; }
Example 20
Source File: KeyManager.java From New-Beginner-Java-Game-Programming-Src with Creative Commons Zero v1.0 Universal | 4 votes |
public void tick(){ up = keys[KeyEvent.VK_W]; down = keys[KeyEvent.VK_S]; left = keys[KeyEvent.VK_A]; right = keys[KeyEvent.VK_D]; }