Example usage for java.awt.event KeyEvent VK_ALT

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

Introduction

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

Prototype

int VK_ALT

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

Click Source Link

Document

Constant for the ALT virtual key.

Usage

From source file:org.eclipse.jubula.rc.common.driver.KeyTyper.java

/**
 * @param keyStroke KeyStroke whose modifiers are requested
 * @return a List of KeyCodes (hopefully) realising the ModifierMask contained in the KeyStroke
 *///from  w w w .  ja v a 2s . com
private List modifierKeyCodes(KeyStroke keyStroke) {
    List l = new LinkedList();
    int modifiers = keyStroke.getModifiers();
    // this is jdk 1.3 - code.
    // use ALT_DOWN_MASK instead etc. with jdk 1.4 !
    if ((modifiers & InputEvent.ALT_MASK) != 0) {
        l.add(new Integer(KeyEvent.VK_ALT));
    }
    if ((modifiers & InputEvent.ALT_GRAPH_MASK) != 0) {
        l.add(new Integer(KeyEvent.VK_ALT_GRAPH));
    }
    if ((modifiers & InputEvent.CTRL_MASK) != 0) {
        l.add(new Integer(KeyEvent.VK_CONTROL));
    }
    if ((modifiers & InputEvent.SHIFT_MASK) != 0) {
        l.add(new Integer(KeyEvent.VK_SHIFT));
    }
    if ((modifiers & InputEvent.META_MASK) != 0) {
        l.add(new Integer(KeyEvent.VK_META));
    }
    return l;
}

From source file:com.ubershy.streamsis.actions.HotkeyAction.java

/**
 * Releases the provided {@link KeyCodeCombination}'s keys.
 *
 * @param kb            the KeyCodeCombination
 * @return true, if successful//w w  w .  j  a va 2  s  .  c o m
 */
@SuppressWarnings("deprecation")
protected boolean keysUp(KeyCodeCombination kb) {
    try {
        // I know this is a bad practice. Do you have any idea how to avoid this, stranger?
        robot.keyRelease(kb.getCode().impl_getCode());
        Thread.sleep(modifiersPressSleepTime);
        if (kb.getShift() == ModifierValue.DOWN) {
            robot.keyRelease(KeyEvent.VK_SHIFT);
            Thread.sleep(modifiersPressSleepTime);
        }
        if (kb.getAlt() == ModifierValue.DOWN) {
            robot.keyRelease(KeyEvent.VK_ALT);
            Thread.sleep(modifiersPressSleepTime);
        }
        if (kb.getShortcut() == ModifierValue.DOWN) {
            robot.keyRelease(shortcutKeyEvent);
        }
    } catch (InterruptedException e) {
        logger.debug("Haha, not this time, InterruptedException!");
        return false;
    }
    return true;
}

From source file:com.photon.phresco.Screens.InvalidJarBase.java

public void instantiateBrowser(String selectedBrowser, String selectedPlatform, String applicationURL,
        String applicationContext) throws ScreenException, MalformedURLException {

    if (selectedBrowser.equalsIgnoreCase(Constants.BROWSER_CHROME)) {
        try {//  w  w w  . ja v a2  s.c  o m
            // "D:/Selenium-jar/chromedriver_win_19.0.1068.0/chromedriver.exe"
            chromeService = new ChromeDriverService.Builder()
                    .usingDriverExecutable(new File(getChromeLocation())).usingAnyFreePort().build();

            log.info("-------------***LAUNCHING GOOGLECHROME***--------------");

            driver = new ChromeDriver(chromeService);
            //driver.manage().window().maximize();
            //   driver = new ChromeDriver(chromeService, chromeOption);
            // driver.manage().timeouts().implicitlyWait(30,
            // TimeUnit.SECONDS);            
            //driver.navigate().to(applicationURL + applicationContext);
            driver.manage().window().maximize();
            driver.navigate().to(applicationURL + applicationContext);

        } catch (Exception e) {
            e.printStackTrace();
        }

    } else if (selectedBrowser.equalsIgnoreCase(Constants.BROWSER_IE)) {
        log.info("---------------***LAUNCHING INTERNET EXPLORE***-----------");
        driver = new InternetExplorerDriver();
        driver.manage().window().maximize();
        driver.navigate().to(applicationURL + applicationContext);

    } else if (selectedBrowser.equalsIgnoreCase(Constants.BROWSER_FIREFOX)) {
        log.info("-------------***LAUNCHING FIREFOX***--------------");
        driver = new FirefoxDriver();
        driver.manage().window().maximize();
        driver.navigate().to(applicationURL + applicationContext);

    } else if (selectedBrowser.equalsIgnoreCase(Constants.BROWSER_OPERA)) {
        log.info("-------------***LAUNCHING OPERA***--------------");
        System.out.println("******entering window maximize********");
        try {
            System.out.println("******entering window maximize********");
            Robot robot;
            try {
                robot = new Robot();
                robot.keyPress(KeyEvent.VK_ALT);
                robot.keyPress(KeyEvent.VK_SPACE);
                robot.keyRelease(KeyEvent.VK_ALT);
                robot.keyRelease(KeyEvent.VK_SPACE);
                robot.keyPress(KeyEvent.VK_X);
                robot.keyRelease(KeyEvent.VK_X);
            } catch (AWTException e) {

                e.printStackTrace();
            }

        } catch (Exception e) {

            e.printStackTrace();
        }

    } else {
        throw new ScreenException("------Only FireFox,InternetExplore and Chrome works-----------");
    }

}

From source file:com.jcraft.weirdx.DDXWindowImpSwing.java

public void keyPressed(KeyEvent e) {
    if (!window.isMapped())
        return;//from   w  w w .  j  a  v a2  s .com

    if (e.getKeyCode() == KeyEvent.VK_CAPS_LOCK) {
        if (clck_toggle) {
            clck_toggle = false;
            XWindow.sprite.hot.state &= (~1);
        } else {
            clck_toggle = true;
            XWindow.sprite.hot.state |= 1;
        }
    }

    // Easter Egg...
    if (window == window.screen.root && 0 < px && px < 3 && 0 < py && py < 3) {
        if (((e.getModifiers() & InputEvent.CTRL_MASK) != 0) && e.getKeyCode() == KeyEvent.VK_W) {
            LogoImage.toggle();
        } else if (((e.getModifiers() & InputEvent.CTRL_MASK) != 0) && e.getKeyCode() == KeyEvent.VK_E) {
            XWindow.printWindowTree(window.screen.root);
        }
        //    else if(((e.getModifiers() & InputEvent.CTRL_MASK)!=0) &&
        //         e.getKeyCode()==KeyEvent.VK_I){
        //   if(WeirdX.acontext!=null){
        //     acontext.showDocument(new URL("http://www.weirdx.org/"), "_blank");
        //   }
        //    }
        //    else if(((e.getModifiers() & InputEvent.CTRL_MASK)!=0) &&
        //         e.getKeyCode()==KeyEvent.VK_R){
        //   }
        //    }
        //    else if(((e.getModifiers() & InputEvent.CTRL_MASK)!=0) &&
        //         e.getKeyCode()==KeyEvent.VK_D){
        //   }
        //    }
        //    else if(((e.getModifiers() & InputEvent.CTRL_MASK)!=0) &&
        //         e.getKeyCode()==KeyEvent.VK_X){
        //   }
        //    }
    }

    XWindow dest = XWindow.sprite.win;
    if (XWindow.focus.window != null)
        dest = XWindow.focus.window;

    if (window.screen.windowmode != 0 && dest == window.screen.root) {
        if (XWindow.focus.window != null)
            dest = XWindow.sprite.win;
        else
            dest = window;
    }

    if (dest.client == null)
        return;

    int kcode = Keymap.km.getCode(e);
    event.mkKeyPress(kcode, window.screen.rootId, dest.id, 0, XWindow.sprite.hot.x, XWindow.sprite.hot.y,
            XWindow.sprite.hot.x - window.x, XWindow.sprite.hot.y - window.y, XWindow.sprite.hot.state, 1);

    try {
        if (XWindow.grab != null)
            XWindow.sendGrabbedEvent(event, false, 1);
        else
            XWindow.sendDeviceEvent(dest, event, XWindow.grab, null, 1);
    } catch (Exception ee) {
    }

    kcode = e.getKeyCode();
    int state = XWindow.sprite.hot.state;
    if (kcode == KeyEvent.VK_CONTROL) {
        if ((state & 4) == 0)
            state |= 4;
    } else if (kcode == KeyEvent.VK_SHIFT) {
        if ((state & 1) == 0)
            state |= 1;
    } else if (kcode == KeyEvent.VK_ALT) {
        if ((state & 8) == 0)
            state |= 8;
    } else if (kcode == VK_ALT_GRAPH) {
        if ((state & ALT_GR_MASK) == 0)
            state |= ALT_GR_MASK;
    }
    // check for windoze ALT_GR (is equal to ALT+CONTROL), by Marcus.
    if ((state & 12) == 12) {
        state -= 12;
        state |= ALT_GR_MASK;
    }

    XWindow.sprite.hot.state = state;
}

From source file:com.jcraft.weirdx.DDXWindowImp.java

public void keyPressed(KeyEvent e) {
    if (!window.isMapped())
        return;/* ww w. j  a v a2s  .  co m*/

    if (e.getKeyCode() == KeyEvent.VK_CAPS_LOCK) {
        if (clck_toggle) {
            clck_toggle = false;
            XWindow.sprite.hot.state &= (~1);
        } else {
            clck_toggle = true;
            XWindow.sprite.hot.state |= 1;
        }
    }

    // Easter Egg...
    if (window == window.screen.root && 0 < px && px < 3 && 0 < py && py < 3) {
        if (((e.getModifiers() & InputEvent.CTRL_MASK) != 0) && e.getKeyCode() == KeyEvent.VK_W) {
            LogoImage.toggle();
        } else if (((e.getModifiers() & InputEvent.CTRL_MASK) != 0) && e.getKeyCode() == KeyEvent.VK_E) {
            XWindow.printWindowTree(window.screen.root);
        }
        //    else if(((e.getModifiers() & InputEvent.CTRL_MASK)!=0) &&
        //         e.getKeyCode()==KeyEvent.VK_I){
        //   if(WeirdX.acontext!=null){
        //     acontext.showDocument(new URL("http://www.weirdx.org/"), "_blank");
        //   }
        //    }
        //    else if(((e.getModifiers() & InputEvent.CTRL_MASK)!=0) &&
        //         e.getKeyCode()==KeyEvent.VK_R){
        //   }
        //    }
        //    else if(((e.getModifiers() & InputEvent.CTRL_MASK)!=0) &&
        //         e.getKeyCode()==KeyEvent.VK_D){
        //   }
        //    }
        //    else if(((e.getModifiers() & InputEvent.CTRL_MASK)!=0) &&
        //         e.getKeyCode()==KeyEvent.VK_X){
        //   }
        //    }
    }

    XWindow dest = XWindow.sprite.win;
    if (XWindow.focus.window != null)
        dest = XWindow.focus.window;

    if (window.screen.windowmode != 0 && dest == window.screen.root) {
        if (XWindow.focus.window != null)
            dest = XWindow.sprite.win;
        else
            dest = window;
    }

    if (dest.client == null)
        return;

    int kcode = Keymap.km.getCode(e);
    event.mkKeyPress(kcode, window.screen.rootId, dest.id, 0, XWindow.sprite.hot.x, XWindow.sprite.hot.y,
            XWindow.sprite.hot.x - window.x, XWindow.sprite.hot.y - window.y, XWindow.sprite.hot.state, 1);

    try {
        if (XWindow.grab != null)
            XWindow.sendGrabbedEvent(event, false, 1);
        else
            XWindow.sendDeviceEvent(dest, event, XWindow.grab, null, 1);
    } catch (Exception ee) {
    }

    kcode = e.getKeyCode();
    int state = XWindow.sprite.hot.state;
    if (kcode == KeyEvent.VK_CONTROL) {
        if ((state & 4) == 0)
            state |= 4;
    } else if (kcode == KeyEvent.VK_SHIFT) {
        if ((state & 1) == 0)
            state |= 1;
    } else if (kcode == KeyEvent.VK_ALT) {
        if ((state & 8) == 0)
            state |= 8;
    } else if (kcode == VK_ALT_GRAPH) {
        if ((state & ALT_GR_MASK) == 0)
            state |= ALT_GR_MASK;
    }
    // check for windoze ALT_GR (is equal to ALT+CONTROL)
    if ((state & 12) == 12) {
        state -= 12;
        state |= ALT_GR_MASK;
    }
    XWindow.sprite.hot.state = state;
}

From source file:com.jcraft.weirdx.DDXWindowImpSwing.java

public void keyReleased(KeyEvent e) {
    if ((window == null) || (!window.isMapped()))
        return;// w ww  .  j  a va2 s  .  c o m
    Client client = window.client;
    if (client == null)
        return;

    int kcode = Keymap.km.getCode(e);
    event.mkKeyRelease(kcode, window.screen.rootId, window.id, 0, XWindow.sprite.hot.x, XWindow.sprite.hot.y,
            XWindow.sprite.hot.x - window.x, XWindow.sprite.hot.y - window.y, XWindow.sprite.hot.state,
            //             state,
            1);

    try {
        if (XWindow.grab != null)
            XWindow.sendGrabbedEvent(event, false, 1);
        else
            XWindow.sendDeviceEvent(window, event, XWindow.grab, null, 1);
    } catch (Exception ee) {
    }

    kcode = e.getKeyCode();
    int state = XWindow.sprite.hot.state;
    if (kcode == KeyEvent.VK_CONTROL) {
        if ((state & 4) != 0)
            state -= 4;
        // check for windoze ALT_GR (is equal to ALT+CONTROL), by Marcus.
        if ((state & ALT_GR_MASK) != 0)
            state -= ALT_GR_MASK;
    } else if (kcode == KeyEvent.VK_SHIFT && !clck_toggle) {
        if ((state & 1) != 0)
            state -= 1;
    } else if (kcode == KeyEvent.VK_ALT) {
        if ((state & 8) != 0)
            state -= 8;
    } else if (kcode == VK_ALT_GRAPH) {
        if ((state & ALT_GR_MASK) != 0)
            state -= ALT_GR_MASK;
    }
    XWindow.sprite.hot.state = state;
}

From source file:com.jcraft.weirdx.DDXWindowImp.java

public void keyReleased(KeyEvent e) {
    if ((window == null) || (!window.isMapped()))
        return;/* ww  w .  j ava  2 s.  c  o m*/
    Client client = window.client;
    if (client == null)
        return;

    int kcode = Keymap.km.getCode(e);
    event.mkKeyRelease(kcode, window.screen.rootId, window.id, 0, XWindow.sprite.hot.x, XWindow.sprite.hot.y,
            XWindow.sprite.hot.x - window.x, XWindow.sprite.hot.y - window.y, XWindow.sprite.hot.state,
            //             state,
            1);

    try {
        if (XWindow.grab != null)
            XWindow.sendGrabbedEvent(event, false, 1);
        else
            XWindow.sendDeviceEvent(window, event, XWindow.grab, null, 1);
    } catch (Exception ee) {
    }

    // change key state
    kcode = e.getKeyCode();
    int state = XWindow.sprite.hot.state;
    if (kcode == KeyEvent.VK_CONTROL) {
        if ((state & 4) != 0)
            state -= 4;
        // check for windoze ALT_GR (is equal to ALT+CONTROL)
        if ((state & ALT_GR_MASK) != 0)
            state -= ALT_GR_MASK;
    } else if (kcode == KeyEvent.VK_SHIFT && !clck_toggle) {
        if ((state & 1) != 0)
            state -= 1;
    } else if (kcode == KeyEvent.VK_ALT) {
        if ((state & 8) != 0)
            state -= 8;
    } else if (kcode == VK_ALT_GRAPH) {
        if ((state & ALT_GR_MASK) != 0)
            state -= ALT_GR_MASK;
    }
    XWindow.sprite.hot.state = state;
}

From source file:com.sshtools.sshterm.emulation.TerminalEmulation.java

public void keyPressed(int keyCode, char keyChar, int modifiers) {
    if (debug > 0) {
        System.out.println("keyPressed(" + keyCode + "," + keyChar + "," + modifiers);
    }/*from  w w w.  j  ava 2s  .c om*/
    boolean control = (modifiers & VDUInput.KEY_CONTROL) != 0;
    boolean shift = (modifiers & VDUInput.KEY_SHIFT) != 0;
    boolean alt = (modifiers & VDUInput.KEY_ALT) != 0;
    int xind;
    String[] fmap;
    xind = 0;
    fmap = FunctionKey;
    if (shift) {
        fmap = FunctionKeyShift;
        xind = 1;
    }
    if (control) {
        fmap = FunctionKeyCtrl;
        xind = 2;
    }
    if (alt) {
        fmap = FunctionKeyAlt;
        xind = 3;
    }
    switch (keyCode) {
    case KeyEvent.VK_PAUSE:
        if (shift || control) {
            sendTelnetCommand((byte) 243);
        }

        // BREAK
        break;
    case KeyEvent.VK_ESCAPE:
        writeSpecial(Escape[xind]);
        break;
    case KeyEvent.VK_F1:
        writeSpecial(fmap[1]);
        break;
    case KeyEvent.VK_F2:
        writeSpecial(fmap[2]);
        break;
    case KeyEvent.VK_F3:
        writeSpecial(fmap[3]);
        break;
    case KeyEvent.VK_F4:
        writeSpecial(fmap[4]);
        break;
    case KeyEvent.VK_F5:
        writeSpecial(fmap[5]);
        break;
    case KeyEvent.VK_F6:
        writeSpecial(fmap[6]);
        break;
    case KeyEvent.VK_F7:
        writeSpecial(fmap[7]);
        break;
    case KeyEvent.VK_F8:
        writeSpecial(fmap[8]);
        break;
    case KeyEvent.VK_F9:
        writeSpecial(fmap[9]);
        break;
    case KeyEvent.VK_F10:
        writeSpecial(fmap[10]);
        break;
    case KeyEvent.VK_F11:
        writeSpecial(fmap[11]);
        break;
    case KeyEvent.VK_F12:
        writeSpecial(fmap[12]);
        break;
    case KeyEvent.VK_UP:
        writeSpecial(KeyUp[xind]);
        break;
    case KeyEvent.VK_DOWN:
        writeSpecial(KeyDown[xind]);
        break;
    case KeyEvent.VK_LEFT:
        writeSpecial(KeyLeft[xind]);
        break;
    case KeyEvent.VK_RIGHT:
        writeSpecial(KeyRight[xind]);
        break;
    case KeyEvent.VK_PAGE_DOWN:
        writeSpecial(NextScn[xind]);
        break;
    case KeyEvent.VK_PAGE_UP:
        writeSpecial(PrevScn[xind]);
        break;
    case KeyEvent.VK_INSERT:
        writeSpecial(Insert[xind]);
        break;
    case KeyEvent.VK_DELETE:
        writeSpecial(Remove[xind]);
        break;
    case KeyEvent.VK_BACK_SPACE:
        writeSpecial(BackSpace[xind]);
        if (localecho) {
            if (BackSpace[xind] == "\b" || BackSpace[xind] == "\u007f") {
                putString("\b \b");
                // make the last char 'deleted'
            } else {
                putString(BackSpace[xind]);
                // echo it
            }
        }
        break;
    case KeyEvent.VK_HOME:
        writeSpecial(KeyHome[xind]);
        break;
    case KeyEvent.VK_END:
        writeSpecial(KeyEnd[xind]);
        break;
    case KeyEvent.VK_NUM_LOCK:
        if (vms && control) {
            writeSpecial(PF1);
        }
        if (!control) {
            numlock = !numlock;
        }
        break;
    case KeyEvent.VK_CAPS_LOCK:
        capslock = !capslock;
        return;
    case KeyEvent.VK_SHIFT:
    case KeyEvent.VK_CONTROL:
    case KeyEvent.VK_ALT:
        return;
    default:
        break;
    }
}

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/*  www  .  j a  va 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:org.safs.selenium.webdriver.lib.WDLibrary.java

/**
 *
 * @param key Keys, the selenium Keys value
 * @return int the value of java KeyEvent
 * @throws SeleniumPlusException/*from  w  ww. j a va 2s .  co  m*/
 */
static int toJavaKeyCode(Keys key) throws SeleniumPlusException {
    String debugmsg = StringUtils.debugmsg(WDLibrary.class, "toJavaKeyCode");
    if (Keys.SHIFT.equals(key))
        return KeyEvent.VK_SHIFT;
    else if (Keys.LEFT_SHIFT.equals(key))
        return KeyEvent.VK_SHIFT;
    else if (Keys.CONTROL.equals(key))
        return KeyEvent.VK_CONTROL;
    else if (Keys.LEFT_CONTROL.equals(key))
        return KeyEvent.VK_CONTROL;
    else if (Keys.ALT.equals(key))
        return KeyEvent.VK_ALT;
    else if (Keys.LEFT_ALT.equals(key))
        return KeyEvent.VK_ALT;
    else {
        String msg = " No handled key '" + (key == null ? "null" : key.toString()) + "'.";
        IndependantLog.debug(debugmsg + msg);
        throw new SeleniumPlusException(msg);
    }
}