Example usage for org.openqa.selenium Keys DOWN

List of usage examples for org.openqa.selenium Keys DOWN

Introduction

In this page you can find the example usage for org.openqa.selenium Keys DOWN.

Prototype

Keys DOWN

To view the source code for org.openqa.selenium Keys DOWN.

Click Source Link

Usage

From source file:org.auraframework.components.ui.menu.MenuUITest.java

License:Apache License

private void testActionMenuViaKeyboardInteractionForApp(String appName)
        throws MalformedURLException, URISyntaxException {
    open(appName);//from   w  w  w  .  j a  v  a 2s  .co  m
    WebDriver driver = this.getDriver();
    String label = "trigger";
    String menuName = "actionMenu";
    String menuItem1 = "actionItem1";
    String menuItem3 = "actionItem3";
    String menuItem4 = "actionItem4";
    WebElement menuLabel = driver.findElement(By.className(label));
    WebElement actionMenu = driver.findElement(By.className(menuName));
    WebElement actionItem1 = driver.findElement(By.className(menuItem1));
    WebElement actionItem1Element = actionItem1.findElement(By.tagName("a"));
    WebElement actionItem3 = driver.findElement(By.className(menuItem3));
    WebElement actionItem3Element = actionItem3.findElement(By.tagName("a"));
    WebElement actionItem4 = driver.findElement(By.className(menuItem4));
    WebElement actionItem4Element = actionItem4.findElement(By.tagName("a"));

    // click on menu list
    menuLabel.click();
    // check menu list is visible after the click
    assertTrue("Menu list should be visible", actionMenu.getAttribute("class").contains("visible"));

    // default focus on action item1
    assertEquals("Focus should be on actionItem1", actionItem1Element.getText(),
            auraUITestingUtil.getActiveElementText());

    // press down key twice
    actionItem1Element.sendKeys(Keys.DOWN, Keys.DOWN);

    // verify focus on action item3
    auraUITestingUtil.setHoverOverElement(menuItem3);
    assertEquals("Focus should be on actionItem3", actionItem3Element.getText(),
            auraUITestingUtil.getActiveElementText());

    actionItem3.click();
    assertEquals("Item3 unchecked after pressing Enter key", "Inter Milan", menuLabel.getText());

    menuLabel.click();
    // focus on action item4
    auraUITestingUtil.setHoverOverElement(menuItem4);
    assertEquals("Focus should be on actionItem4", actionItem4Element.getText(),
            auraUITestingUtil.getActiveElementText());

    actionItem4Element.sendKeys(Keys.UP);
    // verify focus on action item3
    assertEquals("Focus should be on actionItem3", actionItem3Element.getText(),
            auraUITestingUtil.getActiveElementText());

    // press space key and check if item3 got selected
    actionItem3Element.sendKeys(Keys.SPACE);
    assertEquals("Item3 not selected after pressing space key", "Inter Milan", menuLabel.getText());

    menuLabel.click();
    assertTrue("Menu list should be visible", actionMenu.getAttribute("class").contains("visible"));
    auraUITestingUtil.setHoverOverElement(menuItem1);
    actionItem1Element.sendKeys(Keys.ESCAPE);
    assertFalse("Menu list should not be visible", actionMenu.getAttribute("class").contains("visible"));
}

From source file:org.auraframework.components.ui.menu.MenuUITest.java

License:Apache License

private void testMenuCheckboxForApp(String appName) throws MalformedURLException, URISyntaxException {
    open(appName);//from   w  w  w  . j  a  v  a  2 s  .  c  om
    WebDriver driver = this.getDriver();
    String label = "checkboxMenuLabel";
    String menuName = "checkboxMenu";
    String menuItem3 = "checkboxItem3";
    String menuItem4 = "checkboxItem4";
    String globalIdItem3 = auraUITestingUtil.getCmpGlobalIdGivenElementClassName(menuItem3);
    String globalIdItem4 = auraUITestingUtil.getCmpGlobalIdGivenElementClassName(menuItem4);
    String disableValueM4Exp = auraUITestingUtil.getValueFromCmpExpression(globalIdItem4, "v.disabled");
    String selectedValueM4Exp = auraUITestingUtil.getValueFromCmpExpression(globalIdItem4, "v.selected");
    String selectedValueM3Exp = auraUITestingUtil.getValueFromCmpExpression(globalIdItem3, "v.selected");
    WebElement menuLabel = driver.findElement(By.className(label));
    WebElement menu = driver.findElement(By.className(menuName));
    WebElement item3 = driver.findElement(By.className(menuItem3));
    WebElement item3Element = item3.findElement(By.tagName("a"));
    WebElement item4 = driver.findElement(By.className(menuItem4));
    WebElement item4Element = item4.findElement(By.tagName("a"));
    WebElement button = driver.findElement(By.className("checkboxButton"));
    WebElement result = driver.findElement(By.className("result"));

    // check for default label present
    assertEquals("label is wrong", "NFC West Teams", menuLabel.getText());
    assertFalse("Default: CheckboxMenu list should not be visible",
            menu.getAttribute("class").contains("visible"));

    // click on label
    menuLabel.click();

    // verify menu list is visible
    assertTrue("CheckboxMenu list should be visible", menu.getAttribute("class").contains("visible"));

    // verify aria attribute item4 which is used for accessibility is disabled and selected
    assertTrue("Item4 aria attribute should be disabled",
            Boolean.valueOf(item4Element.getAttribute("aria-disabled")));
    assertTrue("Item4 aria attribute should be selected",
            Boolean.valueOf(item4Element.getAttribute("aria-checked")));

    // verify item4 is disabled and selected

    assertTrue("Item4 should be disabled", (Boolean) auraUITestingUtil.getEval(disableValueM4Exp));
    assertTrue("Item4 should be selected", (Boolean) auraUITestingUtil.getEval(selectedValueM4Exp));

    // click on item4
    item4Element.click();
    assertTrue("Item4 aria attribute should be Selected even when clicked",
            Boolean.valueOf(item4Element.getAttribute("aria-checked")));
    assertTrue("Item4 should be Selected even when clicked",
            (Boolean) auraUITestingUtil.getEval(selectedValueM4Exp));

    assertFalse("default: Item3 aria attribute should be Uncheked",
            Boolean.valueOf(item3Element.getAttribute("aria-checked")));
    assertFalse("default: Item3 should be Uncheked", (Boolean) auraUITestingUtil.getEval(selectedValueM3Exp));

    // click on item3
    item3Element.click();
    assertTrue("Item3 aria attribute should be Selected after the click",
            Boolean.valueOf(item3Element.getAttribute("aria-checked")));
    assertTrue("Item3 should be Selected after the click",
            (Boolean) auraUITestingUtil.getEval(selectedValueM3Exp));

    // click on item3 again
    auraUITestingUtil.pressEnter(item3Element);
    // verify not selected
    assertFalse("Item3 aria attribute should be Uncheked after Pressing Enter",
            Boolean.valueOf(item3Element.getAttribute("aria-checked")));
    assertFalse("Item3 should be Uncheked after Pressing Enter",
            (Boolean) auraUITestingUtil.getEval(selectedValueM3Exp));

    item3Element.sendKeys(Keys.SPACE);
    assertTrue("Item3 aria attribute should be checked after Pressing Space",
            Boolean.valueOf(item3Element.getAttribute("aria-checked")));
    assertTrue("Item3 should be checked after Pressing Space",
            (Boolean) auraUITestingUtil.getEval(selectedValueM3Exp));

    // check if focus changes when you use up and down arrow using keyboard
    item3Element.sendKeys(Keys.DOWN);
    assertEquals("Focus should be on item 4", item4Element.getText(), auraUITestingUtil.getActiveElementText());
    item4Element.sendKeys(Keys.UP);
    assertEquals("Focus should be back to item 3", item3Element.getText(),
            auraUITestingUtil.getActiveElementText());

    // press Tab to close to menu
    item3Element.sendKeys(Keys.TAB);

    // verify menu not visible
    assertFalse("CheckboxMenu list should not be visible after escape",
            menu.getAttribute("class").contains("visible"));

    // click on submit button and verify the results
    assertEquals("label value should not get updated", "NFC West Teams", menuLabel.getText());
    button.click();
    assertEquals("Checkbox items selected are not correct", "St. Louis Rams,Arizona Cardinals",
            result.getText());
}

From source file:org.auraframework.components.ui.menu.MenuUITest.java

License:Apache License

public void testMenuRadio() throws MalformedURLException, URISyntaxException {
    open(MENUTEST_APP);/*from ww w. ja va2  s .  c om*/
    WebDriver driver = this.getDriver();
    String label = "radioMenuLabel";
    String menuName = "radioMenu";
    String menuItem3 = "radioItem3";
    String menuItem4 = "radioItem4";
    String menuItem5 = "radioItem5";
    String disableValueM4Exp = auraUITestingUtil.getValueFromCmpRootExpression(menuItem4, "v.disabled");
    WebElement menuLabel = driver.findElement(By.className(label));
    WebElement menu = driver.findElement(By.className(menuName));
    WebElement item3 = driver.findElement(By.className(menuItem3));
    WebElement item3Element = item3.findElement(By.tagName("a"));
    WebElement item4 = driver.findElement(By.className(menuItem4));
    WebElement item4Element = item4.findElement(By.tagName("a"));
    WebElement item5 = driver.findElement(By.className(menuItem5));
    WebElement item5Element = item5.findElement(By.tagName("a"));
    WebElement button = driver.findElement(By.className("radioButton"));
    WebElement result = driver.findElement(By.className("radioResult"));

    // check for default label present
    assertEquals("label is wrong", "National League West", menuLabel.getText());
    assertFalse("Default: CheckboxMenu list should not be visible",
            menu.getAttribute("class").contains("visible"));
    // open menu list
    menuLabel.click();
    // verify menu list is visible
    assertTrue("CheckboxMenu list should be visible", menu.getAttribute("class").contains("visible"));
    item3.click();
    // verify item3 got selected
    assertTrue("Item3 should be selected after the click",
            item3Element.getAttribute("class").contains("selected"));

    // send key to go to item 4 using 'd'
    item3Element.sendKeys("d");
    // verify focus on item 4
    assertEquals("Focus should be on item4 after the search", item4Element.getText(),
            auraUITestingUtil.getActiveElementText());
    // verify item is disabled
    assertTrue("Item4 aria attribute should be defaulted to disable",
            Boolean.valueOf(item4Element.getAttribute("aria-disabled")));
    assertTrue("Item4 should be defaulted to disable", (Boolean) auraUITestingUtil.getEval(disableValueM4Exp));

    // click on item4
    item4Element.click();
    // verify item4 should not be selectable
    assertFalse("Item4 should not be selectable as its disable item",
            item4Element.getAttribute("class").contains("selected"));
    // goto item 5 using down arrow
    item4Element.sendKeys(Keys.DOWN);
    // verify focus on item 5
    assertEquals("Focus should be on item5 after pressing down key", item5Element.getText(),
            auraUITestingUtil.getActiveElementText());
    // click on item 5 using space
    item5Element.sendKeys(Keys.SPACE);
    assertTrue("Item5 should be checked after pressing Space",
            item5Element.getAttribute("class").contains("selected"));
    assertFalse("Item3 should be unchecked after clicking item 5",
            item3Element.getAttribute("class").contains("selected"));
    // close the menu using esc key
    item5Element.sendKeys(Keys.ESCAPE);
    // check the result
    button.click();
    assertEquals("Checkbox items selected are not correct", "Colorado", result.getText());
}

From source file:org.auraframework.integration.test.components.ui.menu.MenuUITest.java

License:Apache License

@Test
public void testOpenMenuViaKeyboardDownKey() throws Exception {
    openMenuViaKeyboardAndTestActionMenu(MENUTEST_APP, Keys.DOWN, "actionItem1", "actionItem2");
}

From source file:org.auraframework.integration.test.components.ui.menu.MenuUITest.java

License:Apache License

private void testActionMenuViaKeyboardInteractionForApp(String appName, String appendString,
        boolean verifyLabelUpdate) throws Exception {
    open(appName);/*from  w  w w.j  a v  a 2 s . c  o m*/
    WebDriver driver = this.getDriver();
    String label = "trigger" + appendString;
    String menuName = "actionMenu" + appendString;
    String menuItem1 = "actionItem1" + appendString;
    String menuItem3 = "actionItem3" + appendString;
    String menuItem4 = "actionItem4" + appendString;
    WebElement menuLabel = driver.findElement(By.className(label));
    WebElement actionMenu = driver.findElement(By.className(menuName));

    openMenu(menuLabel, actionMenu);

    WebElement actionItem1 = driver.findElement(By.className(menuItem1));
    WebElement actionItem1Element = getAnchor(actionItem1);
    WebElement actionItem3 = driver.findElement(By.className(menuItem3));
    WebElement actionItem3Element = getAnchor(actionItem3);
    WebElement actionItem4 = driver.findElement(By.className(menuItem4));
    WebElement actionItem4Element = getAnchor(actionItem4);

    // default focus on trigger
    assertEquals("Focus should be on the trigger", menuLabel.getText(),
            getAuraUITestingUtil().getActiveElementText());

    // press down key once
    menuLabel.sendKeys(Keys.DOWN);

    // focus should be one the first item
    waitForFocusOnElement(actionItem1Element);

    actionItem1Element.sendKeys(Keys.DOWN, Keys.DOWN);

    // verify focus on action item3
    getAuraUITestingUtil().setHoverOverElement(menuItem3);
    waitForFocusOnElement(actionItem3Element);

    actionItem3Element.click();
    if (verifyLabelUpdate) {
        waitForMenuText(menuLabel, "Inter Milan");
    }

    openMenu(menuLabel, actionMenu);
    getAuraUITestingUtil().setHoverOverElement(menuItem4);
    waitForFocusOnElement(actionItem4Element);

    actionItem4Element.sendKeys(Keys.UP);
    // verify focus on action item3
    waitForFocusOnElement(actionItem3Element);

    // press space key and check if item3 got selected
    actionItem3Element.sendKeys(Keys.SPACE);
    if (verifyLabelUpdate) {
        waitForMenuText(menuLabel, "Inter Milan");
    }

    openMenu(menuLabel, actionMenu);
    getAuraUITestingUtil().setHoverOverElement(menuItem1);
    waitForFocusOnElement(actionItem1Element);
    actionItem1Element.sendKeys(Keys.ESCAPE);
    waitForMenuClose(actionMenu);
}

From source file:org.auraframework.integration.test.components.ui.menu.MenuUITest.java

License:Apache License

private void openMenuViaKeyboardAndTestActionMenu(String appName, Keys openKey, String focusAfterOpen,
        String itemExpected) throws Exception {

    open(appName);//from w  ww.j  a v a 2s .c om

    WebDriver driver = this.getDriver();
    WebElement menuLabel = driver.findElement(By.className("trigger"));
    WebElement actionMenu = driver.findElement(By.className("actionMenu"));

    // opening menu using keyboard return or space - focus would remain on the trigger

    WebElement focusAfterOpenElement;

    if ("trigger".equals(focusAfterOpen)) {
        openMenu(menuLabel, actionMenu, openKey);
        focusAfterOpenElement = menuLabel;
        assertEquals("Focus should be on the trigger", menuLabel.getText(),
                getAuraUITestingUtil().getActiveElementText());
    }

    // opening menu using keyboard interaction down button - focus should be on 1st element
    else {
        openMenu(menuLabel, actionMenu, openKey);
        WebElement focusAfterOpenItem = driver.findElement(By.className(focusAfterOpen));
        focusAfterOpenElement = getAnchor(focusAfterOpenItem);
        waitForFocusOnElement(focusAfterOpenElement);
    }

    WebElement expectedItem = driver.findElement(By.className(itemExpected));
    WebElement expectedItemElement = getAnchor(expectedItem);

    focusAfterOpenElement.sendKeys(Keys.DOWN);
    waitForFocusOnElement(expectedItemElement);
}

From source file:org.auraframework.integration.test.components.ui.menu.MenuUITest.java

License:Apache License

private void testMenuCheckboxForApp(String appName) throws Exception {
    open(appName);/*from   w  ww.  j av a  2  s  . c o m*/
    WebDriver driver = this.getDriver();
    String label = "checkboxMenuLabel";
    String menuName = "checkboxMenu";
    String menuItem3 = "checkboxItem3";
    String menuItem4 = "checkboxItem4";
    WebElement menuLabel = driver.findElement(By.className(label));
    WebElement menu = driver.findElement(By.className(menuName));
    WebElement button = driver.findElement(By.className("checkboxButton"));
    By resultLocator = By.className("checkboxMenuResult");

    // check for default label present
    assertEquals("label is wrong", "NFC West Teams", menuLabel.getText());
    assertFalse("Default: CheckboxMenu list should not be visible",
            menu.getAttribute("class").contains("visible"));

    openMenu(menuLabel, menu);

    WebElement item3 = driver.findElement(By.className(menuItem3));
    WebElement item3Element = getAnchor(item3);
    WebElement item4 = driver.findElement(By.className(menuItem4));
    WebElement item4Element = getAnchor(item4);

    // verify aria attribute item4 which is used for accessibility is disabled and selected
    assertTrue("Item4 aria attribute should be disabled",
            Boolean.valueOf(item4Element.getAttribute("aria-disabled")));
    assertTrue("Item4 aria attribute should be selected",
            Boolean.valueOf(item4Element.getAttribute("aria-checked")));

    // verify item4 is disabled and selected
    assertTrue("Item4 should be disabled", getCmpBoolAttribute(menuItem4, "v.disabled"));
    assertTrue("Item4 should be selected", getCmpBoolAttribute(menuItem4, "v.selected"));

    // item4Element is not clickable as it's disabled via markup
    tryToClickDisabledElm(item4Element);

    assertTrue("Item4 aria attribute should be Selected even when clicked",
            Boolean.valueOf(item4Element.getAttribute("aria-checked")));
    assertTrue("Item4 should be Selected even when clicked", getCmpBoolAttribute(menuItem4, "v.selected"));

    assertFalse("default: Item3 aria attribute should be Unchecked",
            Boolean.valueOf(item3Element.getAttribute("aria-checked")));
    assertFalse("default: Item3 should be Unchecked", getCmpBoolAttribute(menuItem3, "v.selected"));

    // check item3 with click
    item3Element.click();
    getAuraUITestingUtil().waitUntil(check -> Boolean.valueOf(item3Element.getAttribute("aria-checked")),
            "Item3 aria attribute should be checked after the click");
    assertTrue("Item3 v.selected should be true after the click", getCmpBoolAttribute(menuItem3, "v.selected"));

    // uncheck item3 with ENTER key
    item3Element.sendKeys(Keys.ENTER);
    getAuraUITestingUtil().waitUntil(check -> !Boolean.valueOf(item3Element.getAttribute("aria-checked")),
            "Item3 aria attribute should be uncheked after pressing ENTER");
    assertFalse("Item3 v.selected should be false after pressing ENTER",
            getCmpBoolAttribute(menuItem3, "v.selected"));

    // check item3 with SPACE key
    item3Element.sendKeys(Keys.SPACE);
    getAuraUITestingUtil().waitUntil(check -> Boolean.valueOf(item3Element.getAttribute("aria-checked")),
            "Item3 aria attribute should be checked after pressing SPACE");
    assertTrue("Item3 v.selected should be true after pressing SPACE",
            getCmpBoolAttribute(menuItem3, "v.selected"));

    // check if focus changes when you use up and down arrow using keyboard
    item3Element.sendKeys(Keys.DOWN);
    waitForFocusOnElement(item4Element);
    item4Element.sendKeys(Keys.UP);
    waitForFocusOnElement(item3Element);

    // press Tab to close to menu
    item3Element.sendKeys(Keys.TAB);
    waitForMenuClose(menu);

    // click on submit button and verify the results
    assertEquals("label value should not get updated", "NFC West Teams", menuLabel.getText());
    button.click();
    getAuraUITestingUtil().waitForElementText(resultLocator, "St. Louis Rams,Arizona Cardinals", true);
}

From source file:org.auraframework.integration.test.components.ui.menu.MenuUITest.java

License:Apache License

@ExcludeBrowsers({ BrowserType.IE11 })
public void testMenuRadio() throws Exception {
    open(MENUTEST_APP);//from   w  w w  .j a va2  s  . c o m
    WebDriver driver = this.getDriver();
    String label = "radioMenuLabel";
    String menuName = "radioMenu";
    String menuItem3 = "radioItem3";
    String menuItem4 = "radioItem4";
    String menuItem5 = "radioItem5";
    WebElement menuLabel = driver.findElement(By.className(label));
    WebElement menu = driver.findElement(By.className(menuName));

    // check for default label present
    assertEquals("label is wrong", "National League West", menuLabel.getText());
    assertFalse("Default: CheckboxMenu list should not be visible",
            menu.getAttribute("class").contains("visible"));

    // open menu list
    openMenu(menuLabel, menu);

    WebElement item3 = driver.findElement(By.className(menuItem3));
    WebElement item3Element = getAnchor(item3);
    WebElement item4 = driver.findElement(By.className(menuItem4));
    WebElement item4Element = getAnchor(item4);
    WebElement item5 = driver.findElement(By.className(menuItem5));
    WebElement item5Element = getAnchor(item5);
    WebElement button = driver.findElement(By.className("radioButton"));
    WebElement result = driver.findElement(By.className("radioMenuResult"));

    // click and verify item3 got selected
    item3Element.click();
    getAuraUITestingUtil().waitUntil(check -> item3Element.getAttribute("class").contains("selected"),
            "Item3 should be selected after the click");

    // send key to go to item 4 using 'd'
    item3Element.sendKeys("d");
    waitForFocusOnElement(item4Element);

    // verify item is disabled
    assertTrue("Item4 aria attribute should be defaulted to disable",
            Boolean.valueOf(item4Element.getAttribute("aria-disabled")));
    assertTrue("Item4 v.disabled should default to true", getCmpBoolAttribute(menuItem4, "v.disabled"));

    // click on item4 and verify item4 should not be selectable
    tryToClickDisabledElm(item4Element);
    assertFalse("Item4 should not be selectable as it's disable item",
            item4Element.getAttribute("class").contains("selected"));

    // goto item 5 using down arrow and check focus
    item4Element.sendKeys(Keys.DOWN);
    waitForFocusOnElement(item5Element);

    // click on item 5 using space
    item5Element.sendKeys(Keys.SPACE);
    getAuraUITestingUtil().waitUntil(check -> item5Element.getAttribute("class").contains("selected"),
            "Item5 should be checked after pressing Space");

    assertFalse("Item3 should be unchecked after clicking item 5",
            item3Element.getAttribute("class").contains("selected"));

    // close the menu using esc key
    item5Element.sendKeys(Keys.ESCAPE);

    // check the result
    button.click();
    assertEquals("Checkbox items selected are not correct", "Colorado", result.getText());
}

From source file:org.auraframework.integration.test.components.ui.menu.MenuUITest.java

License:Apache License

/**
 * Tabbing out of open menu should close menu and focuses on next DOM element
 * Bug: W-3197504/* ww  w.j  a  va2  s. c o  m*/
 */
/*
    @Test
    public void testFocusWhenTabOnOpenMenuWithAttachToBodySet() throws Exception {
open(MENUTEST_ATTACHTOBODY_APP);
String nextFocusableElmClassName = "triggerAttachToBody";
verifyFocusOnTabOnOpenMenu(nextFocusableElmClassName);
    }
*/

private void verifyFocusOnTabOnOpenMenu(String nextFocusableElmClassName) {
    WebDriver driver = this.getDriver();
    WebElement menuElm = driver.findElement(By.className("actionMenu"));
    WebElement triggerElm = driver.findElement(By.className("trigger"));

    // open menu and make sure focus is on the trigger label
    openMenu(triggerElm, menuElm);
    waitForFocusOnElement(triggerElm);

    WebElement item1Elm = driver.findElement(By.className("actionItem1"));
    WebElement nextFocusableElm = driver.findElement(By.className(nextFocusableElmClassName));

    // move the focus to the menuList by moving to the first item
    triggerElm.sendKeys(Keys.DOWN);
    waitForFocusOnElement(item1Elm);

    // tab out to close the menu and check the focus is set to the right element
    if (getBrowserType().equals(BrowserType.FIREFOX)) {
        // firefox closes the menu on the first tab, but the focus is still on the item
        // need a second tab to get to the next element
        getAnchor(item1Elm).sendKeys(Keys.TAB, Keys.TAB);
    } else {
        getAuraUITestingUtil().pressTab(getAnchor(item1Elm));
    }

    waitForFocusOnElement(nextFocusableElm);
}

From source file:org.eclipse.che.selenium.core.action.MacOSActions.java

License:Open Source License

@Override
protected CharSequence[] modifyCharSequence(CharSequence... keysToSend) {
    final List<CharSequence> modKeysToSend = newArrayList();

    for (CharSequence charSequence : keysToSend) {
        final String key = charSequence.toString();

        if (Keys.END.toString().equals(key)) {
            modKeysToSend.add(Keys.chord(Keys.COMMAND, Keys.RIGHT));
        } else if (Keys.HOME.toString().equals(key)) {
            modKeysToSend.add(Keys.chord(Keys.COMMAND, Keys.LEFT));
        } else if (Keys.PAGE_UP.toString().equals(key)) {
            modKeysToSend.add(Keys.chord(Keys.COMMAND, Keys.UP));
        } else if (Keys.PAGE_DOWN.toString().equals(key)) {
            modKeysToSend.add(Keys.chord(Keys.COMMAND, Keys.DOWN));
        } else {//  w  w w . ja v  a  2s.c o m
            modKeysToSend.add(charSequence);
        }
    }

    return modKeysToSend.toArray(new CharSequence[modKeysToSend.size()]);
}