Java Code Examples for java.awt.event.KeyEvent#VK_RIGHT
The following examples show how to use
java.awt.event.KeyEvent#VK_RIGHT .
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: MainPanel.java From javagame with MIT License | 8 votes |
/** * �L�[�������ꂽ��L�[�̏�Ԃ��u�����ꂽ�v�ɕς��� * * @param e �L�[�C�x���g */ public void keyPressed(KeyEvent e) { int keyCode = e.getKeyCode(); if (keyCode == KeyEvent.VK_LEFT) { leftKey.press(); } if (keyCode == KeyEvent.VK_RIGHT) { rightKey.press(); } if (keyCode == KeyEvent.VK_UP) { upKey.press(); } if (keyCode == KeyEvent.VK_DOWN) { downKey.press(); } }
Example 2
Source File: MainPanel.java From JavaBase with MIT License | 6 votes |
@Override public void keyPressed(KeyEvent e) { // if (Move.count == 0) { // randomKey(move); // } if (e.getKeyCode() == KeyEvent.VK_UP) { ImageBlockMgr.move.moveW(); repaint(); } if (e.getKeyCode() == KeyEvent.VK_DOWN) { ImageBlockMgr.move.moveS(); repaint(); } if (e.getKeyCode() == KeyEvent.VK_LEFT) { ImageBlockMgr.move.moveA(); repaint(); } if (e.getKeyCode() == KeyEvent.VK_RIGHT) { ImageBlockMgr.move.moveD(); repaint(); } //继承了JPanel才可以调用repaint函数 repaint(); }
Example 3
Source File: Field.java From JavaRushTasks with MIT License | 6 votes |
@Override public void keyPressed(KeyEvent e) { switch (e.getKeyCode()) { case (KeyEvent.VK_LEFT): eventListener.move(Direction.LEFT); break; case (KeyEvent.VK_RIGHT): eventListener.move(Direction.RIGHT); break; case (KeyEvent.VK_UP): eventListener.move(Direction.UP); break; case (KeyEvent.VK_DOWN): eventListener.move(Direction.DOWN); break; case (KeyEvent.VK_R): eventListener.restart(); break; } }
Example 4
Source File: LeitnerLearnDialog.java From opencards with BSD 2-Clause "Simplified" License | 6 votes |
public boolean postProcessKeyEvent(KeyEvent e) { if (super.postProcessKeyEvent(e)) return true; if (!e.paramString().startsWith("KEY_RELEASED")) return false; if (isShowingComplete()) { switch (e.getKeyCode()) { case KeyEvent.VK_LEFT: fiveButton.getAction().actionPerformed(null); break; case KeyEvent.VK_RIGHT: oneButton.getAction().actionPerformed(null); break; } return true; } return false; }
Example 5
Source File: MainPanel.java From javagame with MIT License | 6 votes |
/** * �L�[�������ꂽ��L�[�̏�Ԃ��u�����ꂽ�v�ɕς��� * * @param e �L�[�C�x���g */ public void keyReleased(KeyEvent e) { int keyCode = e.getKeyCode(); if (keyCode == KeyEvent.VK_LEFT) { leftKey.release(); } if (keyCode == KeyEvent.VK_RIGHT) { rightKey.release(); } if (keyCode == KeyEvent.VK_UP) { upKey.release(); } if (keyCode == KeyEvent.VK_DOWN) { downKey.release(); } }
Example 6
Source File: Ruler.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Override public void keyPressed(KeyEvent e) { int step = e.isControlDown() ? 50 : e.isAltDown() ? 1 : 5; switch (e.getKeyCode()) { case KeyEvent.VK_LEFT: setLocation(getX() - step, getY()); break; case KeyEvent.VK_RIGHT: setLocation(getX() + step, getY()); break; case KeyEvent.VK_UP: setLocation(getX(), getY() - step); break; case KeyEvent.VK_DOWN: setLocation(getX(), getY() + step); break; case KeyEvent.VK_ESCAPE: exitAction.actionPerformed(null); } }
Example 7
Source File: MainPanel.java From javagame with MIT License | 6 votes |
/** * �L�[�������ꂽ��L�[�̏�Ԃ��u�����ꂽ�v�ɕς��� * * @param e �L�[�C�x���g */ public void keyPressed(KeyEvent e) { int keyCode = e.getKeyCode(); if (keyCode == KeyEvent.VK_LEFT) { leftKey.press(); } if (keyCode == KeyEvent.VK_RIGHT) { rightKey.press(); } if (keyCode == KeyEvent.VK_UP) { upKey.press(); } if (keyCode == KeyEvent.VK_DOWN) { downKey.press(); } }
Example 8
Source File: CsvTableEditorKeyListener.java From intellij-csv-validator with Apache License 2.0 | 5 votes |
@Override public void keyReleased(KeyEvent e) { switch (e.getKeyCode()) { case KeyEvent.VK_LEFT: if (e.isControlDown()) { csvTableEditor.tableEditorActions.addColumnBefore.actionPerformed(null); } break; case KeyEvent.VK_RIGHT: if (e.isControlDown()) { csvTableEditor.tableEditorActions.addColumnAfter.actionPerformed(null); } break; case KeyEvent.VK_UP: if (e.isControlDown()) { csvTableEditor.tableEditorActions.addRowBefore.actionPerformed(null); } break; case KeyEvent.VK_DOWN: if (e.isControlDown()) { csvTableEditor.tableEditorActions.addRowAfter.actionPerformed(null); } break; case KeyEvent.VK_ENTER: if (e.isControlDown() && csvTableEditor.isInCellEditMode()) { stopEditing.actionPerformed(null); } else if (!csvTableEditor.isInCellEditMode()) { startEditing.actionPerformed(null); } break; case KeyEvent.VK_DELETE: case KeyEvent.VK_BACK_SPACE: if (e.isControlDown() && e.isShiftDown()) { csvTableEditor.tableEditorActions.deleteColumn.actionPerformed(null); } else if (e.isControlDown()) { csvTableEditor.tableEditorActions.deleteRow.actionPerformed(null); } else if (!csvTableEditor.isInCellEditMode()) { csvTableEditor.tableEditorActions.clearCells.actionPerformed(null); } break; default: break; } }
Example 9
Source File: MainPanel.java From javagame with MIT License | 5 votes |
/** * �L�[�������ꂽ��L�[�̏�Ԃ��u�����ꂽ�v�ɕς��� * * @param e �L�[�C�x���g */ public void keyPressed(KeyEvent e) { int key = e.getKeyCode(); if (key == KeyEvent.VK_LEFT) { leftPressed = true; } if (key == KeyEvent.VK_RIGHT) { rightPressed = true; } if (key == KeyEvent.VK_UP) { upPressed = true; } }
Example 10
Source File: NativeDisplayKeyListener.java From salty-engine with Apache License 2.0 | 5 votes |
@Override public void keyReleased(final KeyEvent e) { if (keyboardHandler != null) { keyboardHandler.keyReleased(e); } currentKey = '*'; if (e.getKeyCode() == KeyEvent.VK_W || e.getKeyCode() == KeyEvent.VK_UP) { inputUp = false; } if (e.getKeyCode() == KeyEvent.VK_S || e.getKeyCode() == KeyEvent.VK_DOWN) { inputDown = false; } if (e.getKeyCode() == KeyEvent.VK_A || e.getKeyCode() == KeyEvent.VK_LEFT) { inputLeft = false; } if (e.getKeyCode() == KeyEvent.VK_D || e.getKeyCode() == KeyEvent.VK_RIGHT) { inputRight = false; } if (SceneManager.getCurrentScene().getUI() != null) { SceneManager.getCurrentScene().getUI().keyReleased(e); } Input.keyboardInput.handleKeyReleased(e); updateInputStates(); Input.lastInput = null; Input.getKeyboardHandlers().forEach(keyboardInputHandler -> keyboardInputHandler.keyReleased(e)); }
Example 11
Source File: CalendarGridPanel.java From microba with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void keyPressed(KeyEvent e) { if (!isEnabled()) return; int id = getFocusedIndex(); int row = id / 7; int col = id % 7; if (e.getKeyCode() == KeyEvent.VK_DOWN) { row++; if (row < 6) { setFocusedByIndex(row * 7 + col); } } if (e.getKeyCode() == KeyEvent.VK_UP) { row--; if (row >= 0) { setFocusedByIndex(row * 7 + col); } } if (e.getKeyCode() == KeyEvent.VK_LEFT) { col--; if (col >= 0) { setFocusedByIndex(row * 7 + col); } } if (e.getKeyCode() == KeyEvent.VK_RIGHT) { col++; if (col < 7) { setFocusedByIndex(row * 7 + col); } } }
Example 12
Source File: NetAdmin.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void keyPressed(KeyEvent e) { if( (e.getKeyCode() != KeyEvent.VK_UP) && (e.getKeyCode() != KeyEvent.VK_DOWN) && (e.getKeyCode() != KeyEvent.VK_LEFT) && (e.getKeyCode() != KeyEvent.VK_RIGHT) && (e.getKeyCode() != KeyEvent.VK_HOME) && (e.getKeyCode() != KeyEvent.VK_END) && (e.getKeyCode() != KeyEvent.VK_PAGE_UP) && (e.getKeyCode() != KeyEvent.VK_PAGE_DOWN) && ((e.getKeyCode() != KeyEvent.VK_A) || (e.isControlDown() == false)) && ((e.getKeyCode() != KeyEvent.VK_C) || (e.isControlDown() == false)) && (!e.isAltDown()) ) { e.consume(); } }
Example 13
Source File: DirectionConfigurator.java From Logisim with GNU General Public License v3.0 | 5 votes |
@Override public KeyConfigurationResult keyEventReceived(KeyConfigurationEvent event) { if (event.getType() == KeyConfigurationEvent.KEY_PRESSED) { KeyEvent e = event.getKeyEvent(); if (e.getModifiersEx() == modsEx) { Direction value = null; switch (e.getKeyCode()) { case KeyEvent.VK_UP: value = Direction.NORTH; break; case KeyEvent.VK_DOWN: value = Direction.SOUTH; break; case KeyEvent.VK_LEFT: value = Direction.WEST; break; case KeyEvent.VK_RIGHT: value = Direction.EAST; break; } if (value != null) { event.consume(); return new KeyConfigurationResult(event, attr, value); } } } return null; }
Example 14
Source File: MainPanel.java From javagame with MIT License | 5 votes |
public void keyPressed(KeyEvent e) { int key = e.getKeyCode(); if (key == KeyEvent.VK_LEFT) { // �u���b�N�����ֈړ� block.move(Block.LEFT); } else if (key == KeyEvent.VK_RIGHT) { // �u���b�N���E�ֈړ� block.move(Block.RIGHT); } else if (key == KeyEvent.VK_DOWN) { // �u���b�N�����ֈړ� block.move(Block.DOWN); } else if (key == KeyEvent.VK_SPACE || key == KeyEvent.VK_UP) { // �u���b�N����] block.turn(); } repaint(); }
Example 15
Source File: MapLayout.java From MeteoInfo with GNU Lesser General Public License v3.0 | 4 votes |
void onKeyPressed(KeyEvent e) { if (_mouseMode == MouseMode.Select) { switch (e.getKeyCode()) { case KeyEvent.VK_DELETE: onRemoveElementClick(); break; case KeyEvent.VK_LEFT: case KeyEvent.VK_RIGHT: case KeyEvent.VK_UP: case KeyEvent.VK_DOWN: int x = 0; int y = 0; int d = 5; if (e.isControlDown()) { d = 1; } switch (e.getKeyCode()) { case KeyEvent.VK_LEFT: x = -d; break; case KeyEvent.VK_RIGHT: x = d; break; case KeyEvent.VK_UP: y = -d; break; case KeyEvent.VK_DOWN: y = d; break; } for (int i = 0; i < _layoutElements.size(); i++) { LayoutElement aElement = _layoutElements.get(i); if (aElement.isSelected()) { if (x != 0) { aElement.setLeft(aElement.getLeft() + x); } if (y != 0) { aElement.setTop(aElement.getTop() + y); } aElement.moveUpdate(); } } //this.paintGraphics(); this.repaintNew(); break; } } }
Example 16
Source File: ActiveBagContentPreviewPanel.java From jclic with GNU General Public License v2.0 | 4 votes |
public boolean processKey(KeyEvent e) { boolean consumed = false; if (cgrid >= 0 && grid[cgrid] != null && tgc[cgrid] != null) { int dx = 0, dy = 0; boolean delete = false, moveFirst = false; Point cur = grid[cgrid].getCursor(); char ch1 = 0; switch (e.getID()) { case KeyEvent.KEY_PRESSED: switch (e.getKeyCode()) { case KeyEvent.VK_RIGHT: dx = 1; break; case KeyEvent.VK_LEFT: dx = -1; break; case KeyEvent.VK_DOWN: dy = 1; break; case KeyEvent.VK_UP: dy = -1; break; case KeyEvent.VK_BACK_SPACE: dx = -1; delete = true; moveFirst = true; break; case KeyEvent.VK_DELETE: delete = true; break; } break; case KeyEvent.KEY_TYPED: char ch0 = e.getKeyChar(); int kk = e.getKeyCode(); if (cur != null) { dx = 1; if (Character.isLetterOrDigit(ch0)) ch1 = Character.toUpperCase(ch0); else if (ch0 == tgc[cgrid].wild || Character.isSpaceChar(ch0)) delete = true; else dx = 0; } break; } if (moveFirst && (dx != 0 || dy != 0)) { moveCursor(dx, dy); cur = grid[cgrid].getCursor(); consumed = true; } if (delete) ch1 = tgc[cgrid].wild; if (ch1 != 0 && cur != null) { if (crossWord) { checkWildChanges(cur, ch1); } grid[cgrid].setCharAt(cur.x, cur.y, ch1); tgc[cgrid].setCharAt(cur.x, cur.y, ch1); setModified(true); consumed = true; } if (!moveFirst && (dx != 0 || dy != 0)) { moveCursor(dx, dy); consumed = true; } } return consumed; }
Example 17
Source File: KeyToggler.java From Any-Angle-Pathfinding with The Unlicense | 4 votes |
@Override public void keyPressed(KeyEvent arg0) { switch(arg0.getKeyCode()) { case KeyEvent.VK_RIGHT : goRight(1, false); break; case KeyEvent.VK_LEFT : goLeft(1, false); break; case KeyEvent.VK_UP : goRight(1, true); break; case KeyEvent.VK_DOWN : goLeft(1, true); break; case KeyEvent.VK_PAGE_UP : goRight(10, false); break; case KeyEvent.VK_PAGE_DOWN : goLeft(10, false); break; case KeyEvent.VK_D : goRight(3, true); break; case KeyEvent.VK_A : goLeft(3, true); break; case KeyEvent.VK_W : goRight(5, true); break; case KeyEvent.VK_S : goLeft(5, true); break; // O: Go right one step + take screenshot, loops around case KeyEvent.VK_O : if (goRight(1, false)) takeSnapShot(); break; // P: Go right one step + take screenshot, stop at end case KeyEvent.VK_P : if (goRight(1, true)) takeSnapShot(); break; // L: Go right multiple steps + take screenshot, stop at end case KeyEvent.VK_L : if (goRight(13, true)) takeSnapShot(); break; // Esc: Close Window case KeyEvent.VK_ESCAPE : System.exit(0); break; } }
Example 18
Source File: VncClientPacketSender.java From cosmic with Apache License 2.0 | 4 votes |
private int mapAwtKeyToVncKey(final 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 19
Source File: CodePointInputMethod.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
/** * This is the input method's main routine. The composed text is stored * in buffer. */ public void dispatchEvent(AWTEvent event) { // This input method handles KeyEvent only. if (!(event instanceof KeyEvent)) { return; } KeyEvent e = (KeyEvent) event; int eventID = event.getID(); boolean notInCompositionMode = buffer.length() == 0; if (eventID == KeyEvent.KEY_PRESSED) { // If we are not in composition mode, pass through if (notInCompositionMode) { return; } switch (e.getKeyCode()) { case KeyEvent.VK_LEFT: moveCaretLeft(); break; case KeyEvent.VK_RIGHT: moveCaretRight(); break; } } else if (eventID == KeyEvent.KEY_TYPED) { char c = e.getKeyChar(); // If we are not in composition mode, wait a back slash if (notInCompositionMode) { // If the type character is not a back slash, pass through if (c != '\\') { return; } startComposition(); // Enter to composition mode } else { switch (c) { case ' ': // Exit from composition mode finishComposition(); break; case '\u007f': // Delete deleteCharacter(); break; case '\b': // BackSpace deletePreviousCharacter(); break; case '\u001b': // Escape cancelComposition(); break; case '\n': // Return case '\t': // Tab sendCommittedText(); break; default: composeUnicodeEscape(c); break; } } } else { // KeyEvent.KEY_RELEASED // If we are not in composition mode, pass through if (notInCompositionMode) { return; } } e.consume(); }
Example 20
Source File: AvatarChooser.java From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License | votes |
@Override public void keyPressed(KeyEvent e) { int keyCode = e.getKeyCode(); switch (keyCode) { case KeyEvent.VK_LEFT: case KeyEvent.VK_UP: scrollAndAnimateBy(-1); break; case KeyEvent.VK_RIGHT: case KeyEvent.VK_DOWN: scrollAndAnimateBy(1); break; case KeyEvent.VK_END: scrollBy(avatars.size() - avatarIndex - 1); break; case KeyEvent.VK_HOME: scrollBy(-avatarIndex - 1); break; case KeyEvent.VK_PAGE_UP: scrollAndAnimateBy(-avatarAmount / 2); break; case KeyEvent.VK_PAGE_DOWN: scrollAndAnimateBy(avatarAmount / 2); break; } }