Example usage for java.awt.event KeyEvent VK_NUMPAD7

List of usage examples for java.awt.event KeyEvent VK_NUMPAD7

Introduction

In this page you can find the example usage for java.awt.event KeyEvent VK_NUMPAD7.

Prototype

int VK_NUMPAD7

To view the source code for java.awt.event KeyEvent VK_NUMPAD7.

Click Source Link

Document

Constant for the number pad "7" key.

Usage

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  v  a  2s .  c o m*/
    //  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:org.safs.selenium.webdriver.lib.WDLibrary.java

/**
 * Convert a Java KEYCODE to a Selenium WebDriver Keys Enum
 * @param keycode int, a java keycode/*from  w  w w . j  a  v  a  2  s.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  ww. ja  va2 s  . c o m
    }

    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;
    }
}