List of usage examples for java.awt.event KeyEvent VK_NUMPAD4
int VK_NUMPAD4
To view the source code for java.awt.event KeyEvent VK_NUMPAD4.
Click Source Link
From source file:haven.GameUI.java
public boolean globtype(char key, KeyEvent ev) { if (key == ':') { entercmd();//from w ww .j a v a2 s .c o m return (true); } else if (key == ' ') { toggleui(); return (true); } else if (key == 3) { if (chat.visible && !chat.hasfocus) { setfocus(chat); } else { if (chat.sz.y == 0) { chat.resize(chat.savedw, chat.savedh); setfocus(chat); } else { chat.resize(0, 0); } } Utils.setprefb("chatvis", chat.sz.y != 0); } else if (key == 16) { /* if((polity != null) && polity.show(!polity.visible)) { polity.raise(); fitwdg(polity); setfocus(polity); } */ return (true); } else if ((key == 27) && (map != null) && !map.hasfocus) { setfocus(map); return (true); } else if (key != 0) { boolean alt = ev.isAltDown(); boolean ctrl = ev.isControlDown(); boolean shift = ev.isShiftDown(); int keycode = ev.getKeyCode(); if (alt && keycode >= KeyEvent.VK_0 && keycode <= KeyEvent.VK_9) { beltwdg.setCurrentBelt(Utils.floormod(keycode - KeyEvent.VK_0 - 1, 10)); return true; } else if (alt && keycode == KeyEvent.VK_S) { studywnd.show(!studywnd.visible); if (studywnd.visible) studywnd.raise(); return true; } else if (alt && keycode == KeyEvent.VK_M) { if (mmapwnd != null) { mmapwnd.togglefold(); return true; } } else if (alt && keycode == KeyEvent.VK_C) { craftwnd.show(!craftwnd.visible); if (craftwnd.visible) craftwnd.raise(); return true; } else if (alt && keycode == KeyEvent.VK_B) { buildwnd.toggle(); if (buildwnd.visible) buildwnd.raise(); return true; } else if (alt && keycode == KeyEvent.VK_N) { Config.nightvision.set(!Config.nightvision.get()); } else if (alt && keycode == KeyEvent.VK_G) { if (map != null) map.gridOverlay.setVisible(!map.gridOverlay.isVisible()); return true; } else if (alt && keycode == KeyEvent.VK_R) { if (mmap != null) mmap.toggleCustomIcons(); return true; } else if (alt && keycode == KeyEvent.VK_D) { if (map != null) map.toggleGobRadius(); return true; } else if (alt && keycode == KeyEvent.VK_Q) { Config.showQuality.set(!Config.showQuality.get()); return true; } else if (alt && keycode == KeyEvent.VK_K) { deckwnd.show(!deckwnd.visible); deckwnd.c = new Coord(sz.sub(deckwnd.sz).div(2)); if (deckwnd.visible) deckwnd.raise(); return true; } else if (alt && keycode == KeyEvent.VK_F) { if (map != null) { map.toggleFriendlyFire(); msg("Friendly fire prevention is now turned " + (map.isPreventFriendlyFireEnabled() ? "on" : "off")); } return true; } else if (alt && keycode == KeyEvent.VK_I) { Config.showGobInfo.set(!Config.showGobInfo.get()); return true; } else if (alt && keycode == KeyEvent.VK_W) { Config.screenshotMode = !Config.screenshotMode; return true; } else if (alt && keycode == KeyEvent.VK_T) { Config.disableTileTransitions.set(!Config.disableTileTransitions.get()); ui.sess.glob.map.rebuild(); return true; } else if (keycode == KeyEvent.VK_Q && ev.getModifiers() == 0) { /* // get all forageables from config List<String> names = new ArrayList<String>(); for (CustomIconGroup group : ui.sess.glob.icons.config.groups) { if ("Forageables".equals(group.name)) { for (CustomIconMatch match : group.matches) if (match.show) names.add(match.value); break; } } tasks.add(new Forager(11 * Config.autopickRadius.get(), 1, names.toArray(new String[names.size()]))); */ ContextTaskFinder.checkForageables(tasks, ui); return true; } else if (keycode == KeyEvent.VK_E && ev.getModifiers() == 0) { ContextTaskFinder.findHandTask(tasks, ui); return true; } else if (keycode == KeyEvent.VK_F && ev.getModifiers() == 0) { ContextTaskFinder.findBuilding(tasks, ui); return true; } else if (keycode >= KeyEvent.VK_NUMPAD1 && keycode <= KeyEvent.VK_NUMPAD4) { tasks.add(new MileStoneTask(Utils.floormod(keycode - KeyEvent.VK_NUMPAD0 - 1, 10))); return true; } else if (keycode == KeyEvent.VK_W && ev.getModifiers() == 0) { tasks.add(new Drunkard()); return true; } else if (shift && keycode == KeyEvent.VK_I) { Config.hideKinInfoForNonPlayers.set(!Config.hideKinInfoForNonPlayers.get()); return true; } else if (ctrl && keycode == KeyEvent.VK_H) { Config.hideModeEnabled.set(!Config.hideModeEnabled.get()); return true; } else if (alt && keycode == KeyEvent.VK_P) { Config.showGobPaths.set(!Config.showGobPaths.get()); return true; } else if (shift && keycode == KeyEvent.VK_W) { if (Config.showQualityMode.get() == 1) { Config.showQualityMode.set(2); } else { Config.showQualityMode.set(1); } return true; } else if (keycode == KeyEvent.VK_TAB && Config.agroclosest.get()) { if (map != null) map.aggroclosest(); return true; } else if (ctrl && keycode == KeyEvent.VK_F) { Config.displayFPS.set(!Config.displayFPS.get()); return true; } else if (keycode == KeyEvent.VK_Z && ev.getModifiers() == 0) { tasks.killAllTasks(); return true; } else if (keycode == 192 && ev.getModifiers() == 0) { getparent(GameUI.class).menu.wdgmsg("act", "travel", "hearth"); return true; } else if (shift && keycode == KeyEvent.VK_S) { HavenPanel.screenshot = true; return true; } } return (super.globtype(key, ev)); }
From source file:com.sshtools.sshterm.emulation.TerminalEmulation.java
public void keyTyped(int keyCode, char keyChar, int modifiers) { if (debug > 0) { System.out.println("keyTyped(" + keyCode + "," + keyChar + "," + modifiers); }/* ww w . j a va 2 s .c om*/ // If there is a scrollbar, scroll to the end if ((display != null) && (display.getScrollBar() != null)) { if (display.getScrollBar().getValue() != display.getScrollBar().getMaximum()) { display.getScrollBar().setValue(display.getScrollBar().getMaximum()); } } boolean control = (modifiers & VDUInput.KEY_CONTROL) != 0; boolean shift = (modifiers & VDUInput.KEY_SHIFT) != 0; // fix problem with Linux Java 6 -- really nasty if (control && keyChar >= 'a' && keyChar <= 'z') keyChar = (char) (keyChar - 96); if (control && shift && keyChar >= 'A' && keyChar <= 'Z') keyChar = (char) (keyChar - 64); boolean alt = (modifiers & VDUInput.KEY_ALT) != 0; if (keyChar == '\t') { if (shift) { write(TabKey[1], false); } else { if (control) { write(TabKey[2], false); } else { if (alt) { write(TabKey[3], false); } else { write(TabKey[0], false); } } } return; } if (alt) { //04/04/07 commented out to stop shortcuts causing strange characters. //write("" + ( (char) (keyChar | 0x80))); return; } if (((keyCode == KeyEvent.VK_ENTER) || (keyChar == 10)) && !control) { if (((eol == EOL_DEFAULT) && sendcrlf) || (eol == EOL_CR_LF)) { write("\r\n", false); if (localecho) { putString("\r\n"); } } else { write("\r", false); if (localecho) { putString("\r"); } } return; } if ((keyCode == 10) && !control) { System.out.println("Sending \\r"); write("\r", false); return; } // FIXME: on german PC keyboards you have to use Alt-Ctrl-q to get an @, // so we can't just use it here... will probably break some other VMS // codes. -Marcus // if(((!vms && keyChar == '2') || keyChar == '@' || keyChar == ' ') // && control) if (((!vms && (keyChar == '2')) || (keyChar == ' ')) && control) { write("" + (char) 0); } if (vms) { if ((keyChar == 127) && !control) { if (shift) { writeSpecial(Insert[0]); } // VMS shift delete = insert else { writeSpecial(Remove[0]); } // VMS delete = remove return; } else if (control) { switch (keyChar) { case '0': writeSpecial(Numpad[0]); return; case '1': writeSpecial(Numpad[1]); return; case '2': writeSpecial(Numpad[2]); return; case '3': writeSpecial(Numpad[3]); return; case '4': writeSpecial(Numpad[4]); return; case '5': writeSpecial(Numpad[5]); return; case '6': writeSpecial(Numpad[6]); return; case '7': writeSpecial(Numpad[7]); return; case '8': writeSpecial(Numpad[8]); return; case '9': writeSpecial(Numpad[9]); return; case '.': writeSpecial(KPPeriod); return; case '-': case 31: writeSpecial(KPMinus); return; case '+': writeSpecial(KPComma); return; case 10: writeSpecial(KPEnter); return; case '/': writeSpecial(PF2); return; case '*': writeSpecial(PF3); return; /* * NUMLOCK handled in keyPressed */ default: break; } } /* * Now what does this do and how did it get here. -Marcus * if (shift && keyChar < 32) { * write(PF1+(char)(keyChar + 64)); * return; * } */ } if (debug > 2) { System.out.println("vt320: keyPressed " + keyCode + "\"" + keyChar + "\""); } // FIXME: not used? String[] fmap; int xind; xind = 0; fmap = FunctionKey; if (shift) { fmap = FunctionKeyShift; xind = 1; } if (control) { fmap = FunctionKeyCtrl; xind = 2; } if (alt) { fmap = FunctionKeyAlt; xind = 3; } if (keyCode == KeyEvent.VK_ESCAPE) { writeSpecial(Escape[xind]); return; } if ((modifiers & VDUInput.KEY_ACTION) != 0) { switch (keyCode) { case KeyEvent.VK_NUMPAD0: writeSpecial(Numpad[0]); return; case KeyEvent.VK_NUMPAD1: writeSpecial(Numpad[1]); return; case KeyEvent.VK_NUMPAD2: writeSpecial(Numpad[2]); return; case KeyEvent.VK_NUMPAD3: writeSpecial(Numpad[3]); return; case KeyEvent.VK_NUMPAD4: writeSpecial(Numpad[4]); return; case KeyEvent.VK_NUMPAD5: writeSpecial(Numpad[5]); return; case KeyEvent.VK_NUMPAD6: writeSpecial(Numpad[6]); return; case KeyEvent.VK_NUMPAD7: writeSpecial(Numpad[7]); return; case KeyEvent.VK_NUMPAD8: writeSpecial(Numpad[8]); return; case KeyEvent.VK_NUMPAD9: writeSpecial(Numpad[9]); return; case KeyEvent.VK_DECIMAL: writeSpecial(NUMDot[xind]); return; case KeyEvent.VK_ADD: writeSpecial(NUMPlus[xind]); return; } } if (!((keyChar == 8) || (keyChar == 127) || (keyChar == '\r') || (keyChar == '\n'))) { write("" + keyChar); return; } }
From source file:com.willwinder.universalgcodesender.MainWindow.java
private void initProgram() { Localization.initialize(this.settings.getLanguage()); try {/* w w w. java 2 s .co m*/ backend.applySettings(settings); } catch (Exception e) { displayErrorDialog(e.getMessage()); } this.setLocalLabels(); this.loadPortSelector(); this.checkScrollWindow(); this.loadFirmwareSelector(); this.setTitle( Localization.getString("title") + " (" + Localization.getString("version") + " " + VERSION + ")"); // Command History this.manualCommandHistory = new ArrayList<>(); // Add keyboard listener for manual controls. KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new KeyEventDispatcher() { @Override public boolean dispatchKeyEvent(KeyEvent e) { // Check context. if (((arrowMovementEnabled.isSelected()) && e.getID() == KeyEvent.KEY_PRESSED) && xPlusButton.isEnabled()) { switch (e.getKeyCode()) { case KeyEvent.VK_RIGHT: case KeyEvent.VK_KP_RIGHT: case KeyEvent.VK_NUMPAD6: xPlusButtonActionPerformed(null); e.consume(); return true; case KeyEvent.VK_LEFT: case KeyEvent.VK_KP_LEFT: case KeyEvent.VK_NUMPAD4: xMinusButtonActionPerformed(null); e.consume(); return true; case KeyEvent.VK_UP: case KeyEvent.VK_KP_UP: case KeyEvent.VK_NUMPAD8: yPlusButtonActionPerformed(null); e.consume(); return true; case KeyEvent.VK_DOWN: case KeyEvent.VK_KP_DOWN: case KeyEvent.VK_NUMPAD2: yMinusButtonActionPerformed(null); e.consume(); return true; case KeyEvent.VK_PAGE_UP: case KeyEvent.VK_NUMPAD9: zPlusButtonActionPerformed(null); e.consume(); return true; case KeyEvent.VK_PAGE_DOWN: case KeyEvent.VK_NUMPAD3: zMinusButtonActionPerformed(null); e.consume(); return true; case KeyEvent.VK_ADD: increaseStepActionPerformed(null); e.consume(); return true; case KeyEvent.VK_SUBTRACT: decreaseStepActionPerformed(null); e.consume(); return true; case KeyEvent.VK_DIVIDE: divideStepActionPerformed(null); e.consume(); return true; case KeyEvent.VK_MULTIPLY: multiplyStepActionPerformed(null); e.consume(); return true; case KeyEvent.VK_INSERT: case KeyEvent.VK_NUMPAD0: resetCoordinatesButtonActionPerformed(null); e.consume(); return true; default: break; } } return false; } }); }
From source file:org.safs.selenium.webdriver.lib.WDLibrary.java
/** * Convert a Java KEYCODE to a Selenium WebDriver Keys Enum * @param keycode int, a java keycode// w ww . j a v a 2s. c o m * @return Keys enum for (primarily) non-printable (control) characters, or null. */ public static Keys convertToKeys(int keycode) { Keys key = null; switch (keycode) { case java.awt.event.KeyEvent.VK_ADD: key = Keys.ADD; break; case java.awt.event.KeyEvent.VK_ALT: key = Keys.ALT; break; case java.awt.event.KeyEvent.VK_KP_DOWN: key = Keys.ARROW_DOWN; break; case java.awt.event.KeyEvent.VK_KP_LEFT: key = Keys.ARROW_LEFT; break; case java.awt.event.KeyEvent.VK_KP_RIGHT: key = Keys.ARROW_RIGHT; break; case java.awt.event.KeyEvent.VK_KP_UP: key = Keys.ARROW_UP; break; case java.awt.event.KeyEvent.VK_BACK_SPACE: key = Keys.BACK_SPACE; break; case java.awt.event.KeyEvent.VK_CANCEL: key = Keys.CANCEL; break; case java.awt.event.KeyEvent.VK_CLEAR: key = Keys.CLEAR; break; case java.awt.event.KeyEvent.VK_WINDOWS: key = Keys.COMMAND; break; case java.awt.event.KeyEvent.VK_CONTROL: key = Keys.CONTROL; break; case java.awt.event.KeyEvent.VK_DECIMAL: key = Keys.DECIMAL; break; case java.awt.event.KeyEvent.VK_DELETE: key = Keys.DELETE; break; case java.awt.event.KeyEvent.VK_DIVIDE: key = Keys.DIVIDE; break; case java.awt.event.KeyEvent.VK_DOWN: key = Keys.DOWN; break; case java.awt.event.KeyEvent.VK_END: key = Keys.END; break; case java.awt.event.KeyEvent.VK_ENTER: key = Keys.ENTER; break; case java.awt.event.KeyEvent.VK_EQUALS: key = Keys.EQUALS; break; case java.awt.event.KeyEvent.VK_ESCAPE: key = Keys.ESCAPE; break; case java.awt.event.KeyEvent.VK_F1: key = Keys.F1; break; case java.awt.event.KeyEvent.VK_F2: key = Keys.F2; break; case java.awt.event.KeyEvent.VK_F3: key = Keys.F3; break; case java.awt.event.KeyEvent.VK_F4: key = Keys.F4; break; case java.awt.event.KeyEvent.VK_F5: key = Keys.F5; break; case java.awt.event.KeyEvent.VK_F6: key = Keys.F6; break; case java.awt.event.KeyEvent.VK_F7: key = Keys.F7; break; case java.awt.event.KeyEvent.VK_F8: key = Keys.F8; break; case java.awt.event.KeyEvent.VK_F9: key = Keys.F9; break; case java.awt.event.KeyEvent.VK_F10: key = Keys.F10; break; case java.awt.event.KeyEvent.VK_F11: key = Keys.F11; break; case java.awt.event.KeyEvent.VK_F12: key = Keys.F12; break; case java.awt.event.KeyEvent.VK_HELP: key = Keys.HELP; break; case java.awt.event.KeyEvent.VK_HOME: key = Keys.HOME; break; case java.awt.event.KeyEvent.VK_INSERT: key = Keys.INSERT; break; case java.awt.event.KeyEvent.VK_LEFT: key = Keys.LEFT; break; case java.awt.event.KeyEvent.VK_META: key = Keys.META; break; case java.awt.event.KeyEvent.VK_MULTIPLY: key = Keys.MULTIPLY; break; case java.awt.event.KeyEvent.VK_NUMPAD0: key = Keys.NUMPAD0; break; case java.awt.event.KeyEvent.VK_NUMPAD1: key = Keys.NUMPAD1; break; case java.awt.event.KeyEvent.VK_NUMPAD2: key = Keys.NUMPAD2; break; case java.awt.event.KeyEvent.VK_NUMPAD3: key = Keys.NUMPAD3; break; case java.awt.event.KeyEvent.VK_NUMPAD4: key = Keys.NUMPAD4; break; case java.awt.event.KeyEvent.VK_NUMPAD5: key = Keys.NUMPAD5; break; case java.awt.event.KeyEvent.VK_NUMPAD6: key = Keys.NUMPAD6; break; case java.awt.event.KeyEvent.VK_NUMPAD7: key = Keys.NUMPAD7; break; case java.awt.event.KeyEvent.VK_NUMPAD8: key = Keys.NUMPAD8; break; case java.awt.event.KeyEvent.VK_NUMPAD9: key = Keys.NUMPAD9; break; case java.awt.event.KeyEvent.VK_PAGE_DOWN: key = Keys.PAGE_DOWN; break; case java.awt.event.KeyEvent.VK_PAGE_UP: key = Keys.PAGE_UP; break; case java.awt.event.KeyEvent.VK_PAUSE: key = Keys.PAUSE; break; case java.awt.event.KeyEvent.VK_RIGHT: key = Keys.RIGHT; break; case java.awt.event.KeyEvent.VK_SEMICOLON: key = Keys.SEMICOLON; break; case java.awt.event.KeyEvent.VK_SEPARATOR: key = Keys.SEPARATOR; break; case java.awt.event.KeyEvent.VK_SHIFT: key = Keys.SHIFT; break; case java.awt.event.KeyEvent.VK_SPACE: key = Keys.SPACE; break; case java.awt.event.KeyEvent.VK_SUBTRACT: key = Keys.SUBTRACT; break; case java.awt.event.KeyEvent.VK_TAB: key = Keys.TAB; break; case java.awt.event.KeyEvent.VK_UP: key = Keys.UP; break; } return key; }
From source file:pl.edu.icm.visnow.geometries.viewer3d.Display3DPanel.java
private void formKeyPressed(KeyEvent evt) { if (lockView) { return;//from w w w .ja v a2s .c om } double dAngle = Math.PI / 144; double dScale = 129. / 128.; if (storingFrames) { dAngle = Math.PI / 360; dScale = 513. / 512.; } if ((evt.getModifiers() & KeyEvent.CTRL_MASK) != 0) { dAngle = Math.PI / 2; } if ((evt.getModifiers() & KeyEvent.SHIFT_MASK) != 0) { dAngle = Math.PI / 6; } objRotate.getTransform(tempTransform); Transform3D rot = new Transform3D(); switch (evt.getKeyCode()) { case KeyEvent.VK_NUMPAD5: reset(); break; case KeyEvent.VK_DOWN: case KeyEvent.VK_KP_DOWN: case KeyEvent.VK_NUMPAD2: rot.rotX(dAngle); break; case KeyEvent.VK_UP: case KeyEvent.VK_KP_UP: case KeyEvent.VK_NUMPAD8: rot.rotX(-dAngle); break; case KeyEvent.VK_LEFT: case KeyEvent.VK_KP_LEFT: case KeyEvent.VK_NUMPAD4: rot.rotY(-dAngle); break; case KeyEvent.VK_RIGHT: case KeyEvent.VK_KP_RIGHT: case KeyEvent.VK_NUMPAD6: rot.rotY(dAngle); break; case KeyEvent.VK_PAGE_UP: case KeyEvent.VK_NUMPAD9: rot.rotZ(dAngle); break; case KeyEvent.VK_PAGE_DOWN: case KeyEvent.VK_NUMPAD3: rot.rotZ(-dAngle); break; } rot.mul(tempTransform); objRotate.setTransform(rot); switch (evt.getKeyCode()) { case KeyEvent.VK_HOME: case KeyEvent.VK_NUMPAD7: mouseScale *= dScale; break; case KeyEvent.VK_END: case KeyEvent.VK_NUMPAD1: mouseScale /= dScale; break; } tempTransform = new Transform3D(new Matrix3d(1., 0., 0., 0., 1., 0., 0., 0., 1.), //sceneCenter, new Vector3d(0.0, 0.0, 0.0), externScale * mouseScale); objScale.setTransform(tempTransform); switch (evt.getKeyCode()) { case CAMERA_UP_KEY: cameraUpKeyPressed = true; processCameraKeys(evt); break; case CAMERA_DOWN_KEY: cameraDownKeyPressed = true; processCameraKeys(evt); break; case CAMERA_LEFT_KEY: cameraLeftKeyPressed = true; processCameraKeys(evt); break; case CAMERA_RIGHT_KEY: cameraRightKeyPressed = true; processCameraKeys(evt); break; case CAMERA_FORWARD_KEY: cameraForwardKeyPressed = true; processCameraKeys(evt); break; case CAMERA_BACKWARD_KEY: cameraBackwardKeyPressed = true; processCameraKeys(evt); break; // TODO milimetr: delete the code below after testing case '8': pickObject.setPickModuleMode(1); break; case '9': pickObject.setPickModuleMode(2); break; case '0': pickObject.setPickModuleMode(3); break; default: break; } }