Java Code Examples for java.awt.event.KeyEvent#VK_UP

The following examples show how to use java.awt.event.KeyEvent#VK_UP . 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: Keys.java    From SikuliNG with MIT License 8 votes vote down vote up
public static boolean isRepeatable(String token) {
  int key = toJavaKeyCodeFromText(token);
  switch (key) {
    case KeyEvent.VK_UP:
      return true;
    case KeyEvent.VK_DOWN:
      return true;
    case KeyEvent.VK_RIGHT:
      return true;
    case KeyEvent.VK_LEFT:
      return true;
    case -KeyEvent.VK_TAB:
      return true;
    case KeyEvent.VK_TAB:
      return true;
    case KeyEvent.VK_ENTER:
      return true;
    case KeyEvent.VK_BACK_SPACE:
      return true;
  }
  return false;
}
 
Example 2
Source File: ShortcutPopupPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void listKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_listKeyPressed
    // UP / DOWN just wraps around the list
    // TODO: convert to action & bind to action map
    int index = list.getSelectedIndex();
    if (evt.getKeyCode() == KeyEvent.VK_UP) {
        list.setSelectedIndex(index == 0 ? model.getSize() - 1 : index - 1);
    } 
    if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
        list.setSelectedIndex(index == (model.getSize() - 1) ? 0 : index + 1);
    }
    if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
        if (!list.isSelectionEmpty()) {
            itemSelected(list.getSelectedIndex());
        }
    }
    evt.consume();
}
 
Example 3
Source File: MainPanel.java    From javagame with MIT License 6 votes vote down vote up
/**
 * �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();
    }
    if (keyCode == KeyEvent.VK_SPACE) {
        spaceKey.press();
    }
}
 
Example 4
Source File: UndoTranslateAll.java    From energy2d with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void redo() throws CannotRedoException {
	super.redo();
	switch (keyCode) {
	case KeyEvent.VK_LEFT:
	case KeyEvent.VK_RIGHT:
		view.translateAllBy(delta, 0);
		break;
	case KeyEvent.VK_UP:
	case KeyEvent.VK_DOWN:
		view.translateAllBy(0, delta);
		break;
	}
	view.getModel().refreshMaterialPropertyArrays();
	view.getModel().refreshPowerArray();
	view.getModel().refreshTemperatureBoundaryArray();
	view.repaint();
}
 
Example 5
Source File: Ruler.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
@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 6
Source File: CsvTableEditorKeyListenerTest.java    From intellij-csv-validator with Apache License 2.0 6 votes vote down vote up
public void testAddRowBeforeAction() {
    KeyEvent keyEvent = new KeyEvent(fileEditor.getTable(), KeyEvent.KEY_RELEASED, JComponent.WHEN_FOCUSED,
            KeyEvent.CTRL_DOWN_MASK, KeyEvent.VK_UP, KeyEvent.CHAR_UNDEFINED);

    fileEditor.tableEditorKeyListener.keyReleased(keyEvent);
    Object[][] newState = fileEditor.getDataHandler().getCurrentState();
    assertEquals(initialState.length + 1, newState.length);
    assertEquals("", newState[0][0]);
    assertEquals("", newState[0][1]);

    fileEditor.tableEditorActions.undo.actionPerformed(null);

    fileEditor.getTable().setRowSelectionInterval(1, 1);
    fileEditor.getTable().setColumnSelectionInterval(1, 1);
    fileEditor.tableEditorKeyListener.keyReleased(keyEvent);
    newState = fileEditor.getDataHandler().getCurrentState();
    assertEquals(initialState.length + 1, newState.length);
    assertEquals("", newState[1][0]);
    assertEquals("", newState[1][1]);
    assertEquals(2, fileEditor.getTable().getSelectedRow());
    assertEquals(1, fileEditor.getTable().getSelectedColumn());
}
 
Example 7
Source File: MainPanel.java    From javagame with MIT License 6 votes vote down vote up
/**
 * �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 8
Source File: ComboCompletionDialog.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
private void jTxtItemKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTxtItemKeyPressed

        int i = jLstItems.getSelectedIndex();
        switch (evt.getKeyCode()) {
            case KeyEvent.VK_ESCAPE:
                result = jTxtItem.getText();
                setVisible(false);
                return;
            case KeyEvent.VK_DOWN:
                if (i < jLstItems.getModel().getSize() - 1) {
                    i++;
                }
                jLstItems.setSelectedIndex(i);
                jLstItems.ensureIndexIsVisible(i);
                break;
            case KeyEvent.VK_UP:
                if (i > 0) {
                    i--;
                }
                jLstItems.setSelectedIndex(i);
                jLstItems.ensureIndexIsVisible(i);
                break;
        }

        if (escapeChars.indexOf(evt.getKeyChar()) >= 0) {
            if (jLstItems.getSelectedIndex() >= 0) {
                result = jLstItems.getSelectedValue().toString();
            } else {
                result = jTxtItem.getText();
            }
            char pressed = evt.getKeyChar();
            // we need to just accept ENTER, and replace the tab with a single
            // space
            if (pressed != '\n') {
                result += (pressed == '\t') ? ' ' : pressed;
            }
            setVisible(false);
        }
    }
 
Example 9
Source File: MainPanel.java    From javagame with MIT License 5 votes vote down vote up
/**
 * �L�[�������ꂽ��L�[�̏�Ԃ��u�����ꂽ�v�ɕς���
 * 
 * @param e �L�[�C�x���g
 */
public void keyReleased(KeyEvent e) {
    int key = e.getKeyCode();

    if (key == KeyEvent.VK_LEFT) {
        leftPressed = false;
    }
    if (key == KeyEvent.VK_RIGHT) {
        rightPressed = false;
    }
    if (key == KeyEvent.VK_UP) {
        upPressed = false;
    }
}
 
Example 10
Source File: AbstractBlock.java    From JavaGame with MIT License 5 votes vote down vote up
/**
 * ���̰����¼�
 * 
 * @param e
 */
public void keyPressed(KeyEvent e) {
	switch (e.getKeyCode()) {
	case KeyEvent.VK_UP:
	case KeyEvent.VK_W:
		direction = Direction.ROTATE;
		break;
	case KeyEvent.VK_DOWN:
	case KeyEvent.VK_S:
		direction = Direction.DOWN;
		break;
	case KeyEvent.VK_LEFT:
	case KeyEvent.VK_A:
		if (x <= Constant.GAME_X_LEFT) {// ��߽�
			direction = Direction.NORMAL;
		} else {
			direction = Direction.LEFT;
		}
		break;
	case KeyEvent.VK_RIGHT:
	case KeyEvent.VK_D:
		if (maxX >= Constant.GAME_X_RIGHT - Constant.BLOCK_WIDTH / 2) {// �ұ߽�
			direction = Direction.NORMAL;
		} else {
			direction = Direction.RIGHT;
		}
		break;
	}
}
 
Example 11
Source File: AccessibilityWindow.java    From megamek with GNU General Public License v2.0 5 votes vote down vote up
public void keyPressed(KeyEvent ev) {
    if (ev.getKeyCode() == KeyEvent.VK_ENTER) {
        history.addFirst(inputField.getText());
        historyBookmark = -1;

        if (inputField.getText().startsWith(Client.CLIENT_COMMAND)) {
            systemEvent(client.runCommand(inputField.getText()));
        } else if (inputField.getText().startsWith(ACCESSIBLE_GUI_SHORTCUT)) {
            processAccessibleGUI();
            systemEvent("Selected " + selectedTarget.toFriendlyString() + " in the GUI.");
        } else {
            client.sendChat(inputField.getText());
        }
        inputField.setText(""); //$NON-NLS-1$

        if (history.size() > MAX_HISTORY) {
            history.removeLast();
        }
    } else if (ev.getKeyCode() == KeyEvent.VK_UP) {
        historyBookmark++;
        fetchHistory();
    } else if (ev.getKeyCode() == KeyEvent.VK_DOWN) {
        historyBookmark--;
        fetchHistory();
    }
    moveToEnd();
}
 
Example 12
Source File: GuiSelectionListener.java    From niftyeditor with Apache License 2.0 5 votes vote down vote up
private void absoluteBehavior(GElement sel,int key){
    Element parent = sel.getParent().getNiftyElement();
    int xp = parent.getX();
    int yp = parent.getY();
    int totalPaddingHorz = parent.getPaddingLeft().getValueAsInt(parent.getWidth());
    int totalPaddingVert = parent.getPaddingTop().getValueAsInt(parent.getHeight());
    int x = sel.getNiftyElement().getX()-(xp+totalPaddingHorz);
    int y = sel.getNiftyElement().getY()-(yp+totalPaddingVert);
    if(key==KeyEvent.VK_DOWN){
        y++;
        sel.addAttribute("y", ""+y);
        sel.lightRefresh();
    }else  if(key==KeyEvent.VK_UP){
        y--;
        sel.addAttribute("y", ""+y);
        sel.lightRefresh();
    }else  if(key==KeyEvent.VK_LEFT){
        x--;
        sel.addAttribute("x", ""+x);
        sel.lightRefresh();
    }else  if(key==KeyEvent.VK_RIGHT){
        x++;
        sel.addAttribute("x", ""+x);
        sel.lightRefresh();
    }
    niftyView.displayRect(x, y,sel.getNiftyElement().getHeight(), sel.getNiftyElement().getWidth() );
  this.selected.setRect(sel.getNiftyElement().getX(), sel.getNiftyElement().getY(),sel.getNiftyElement().getWidth(), sel.getNiftyElement().getHeight() );
}
 
Example 13
Source File: MainPanel.java    From javagame with MIT License 5 votes vote down vote up
/**
 * �L�[�������ꂽ��L�[�̏�Ԃ��u�����ꂽ�v�ɕς���
 * 
 * @param e �L�[�C�x���g
 */
public void keyReleased(KeyEvent e) {
    int key = e.getKeyCode();

    if (key == KeyEvent.VK_LEFT) {
        leftPressed = false;
    }
    if (key == KeyEvent.VK_RIGHT) {
        rightPressed = false;
    }
    if (key == KeyEvent.VK_UP) {
        upPressed = false;
    }
}
 
Example 14
Source File: ColorPickerPanel.java    From PyramidShader with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void keyPressed(KeyEvent e) {
	int dx = 0;
	int dy = 0;
	if(e.getKeyCode()==KeyEvent.VK_LEFT) {
		dx = -1;
	} else if(e.getKeyCode()==KeyEvent.VK_RIGHT) {
		dx = 1;
	} else if(e.getKeyCode()==KeyEvent.VK_UP) {
		dy = -1;
	} else if(e.getKeyCode()==KeyEvent.VK_DOWN) {
		dy = 1;
	}
	int multiplier = 1;
	if(e.isShiftDown() && e.isAltDown()) {
		multiplier = 10;
	} else if(e.isShiftDown() || e.isAltDown()) {
		multiplier = 5;
	}
	if(dx!=0 || dy!=0) {
		int size = Math.min(MAX_SIZE, Math.min(getWidth()-imagePadding.left-imagePadding.right,getHeight()-imagePadding.top-imagePadding.bottom));
		
		int offsetX = getWidth()/2-size/2;
		int offsetY = getHeight()/2-size/2;
		mouseListener.mousePressed(new MouseEvent(ColorPickerPanel.this,
				MouseEvent.MOUSE_PRESSED,
				System.currentTimeMillis(), 0,
				point.x+multiplier*dx+offsetX,
				point.y+multiplier*dy+offsetY,
				1, false
				));
	}
}
 
Example 15
Source File: MenuInput.java    From JavaGame with GNU Affero General Public License v3.0 4 votes vote down vote up
private void toggleKey(int keyCode) {

		if (keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_W) {
			Menu.setSelectedStart(true);
			Menu.setSelectedExit(false);
		}

		if (keyCode == KeyEvent.VK_DOWN || keyCode == KeyEvent.VK_S) {
			Menu.setSelectedExit(true);
			Menu.setSelectedStart(false);
		}

		if(!ticket){
			if (keyCode == KeyEvent.VK_ENTER || keyCode == KeyEvent.VK_SPACE) {
				if (Menu.isSelectedStart()) {
					this.ticket = true;
					Menu.setRunning(false);
					Menu.getFrame().setVisible(false);
					Menu.getFrame().stopFrame();
					new Game().start();
				}

				if (Menu.isSelectedExit()) {
					this.ticket = true;
					Menu.setRunning(false);
					Menu.getFrame().setVisible(false);
					Menu.getFrame().stopFrame();
				}
			}
		}

		if (keyCode == KeyEvent.VK_ESCAPE) {
			System.exit(1);
		}

		if (keyCode == KeyEvent.VK_H){
			HelpMenu h = new HelpMenu();
			if (!help)
				h.run();
			help = true;
		}
	}
 
Example 16
Source File: StaffApplication.java    From RemoteSupportTool with Apache License 2.0 4 votes vote down vote up
@Override
@SuppressWarnings("Duplicates")
protected synchronized void doHandleKeyRelease(KeyEvent e) {
    if (handler == null) return;
    //LOGGER.debug("key released: " + e.paramString());

    // Get code of the released key.
    // Keypad arrows are translated to regular arrow keys.
    final int keyCode;
    switch (e.getKeyCode()) {
        case KeyEvent.VK_KP_DOWN:
            keyCode = KeyEvent.VK_DOWN;
            break;
        case KeyEvent.VK_KP_LEFT:
            keyCode = KeyEvent.VK_LEFT;
            break;
        case KeyEvent.VK_KP_RIGHT:
            keyCode = KeyEvent.VK_RIGHT;
            break;
        case KeyEvent.VK_KP_UP:
            keyCode = KeyEvent.VK_UP;
            break;
        default:
            keyCode = e.getKeyCode();
            break;
    }

    // Never press undefined key codes.
    if (keyCode == KeyEvent.VK_UNDEFINED) {
        return;
    }

    // Never send caps lock, num lock and scroll lock key.
    if (keyCode == KeyEvent.VK_CAPS_LOCK || keyCode == KeyEvent.VK_NUM_LOCK || keyCode == KeyEvent.VK_SCROLL_LOCK) {
        return;
    }

    // Detect, if a control key was pressed.
    final boolean isControlKey = e.isActionKey() ||
            keyCode == KeyEvent.VK_BACK_SPACE ||
            keyCode == KeyEvent.VK_DELETE ||
            keyCode == KeyEvent.VK_ENTER ||
            keyCode == KeyEvent.VK_SPACE ||
            keyCode == KeyEvent.VK_TAB ||
            keyCode == KeyEvent.VK_ESCAPE ||
            keyCode == KeyEvent.VK_ALT ||
            keyCode == KeyEvent.VK_ALT_GRAPH ||
            keyCode == KeyEvent.VK_CONTROL ||
            keyCode == KeyEvent.VK_SHIFT ||
            keyCode == KeyEvent.VK_META;

    // Release control keys.
    if (isControlKey) {
        //LOGGER.debug("release key \"{}\" ({})", keyCode, KeyEvent.getKeyText(keyCode));
        handler.sendKeyRelease(keyCode);
        e.consume();
    }

    // Release other keys, if they are pressed together with a modifier key.
    else if (e.isControlDown() || e.isMetaDown() || windowsKeyDown || (!SystemUtils.IS_OS_MAC && e.isAltDown()) || pressedKeys.contains(keyCode)) {
        //LOGGER.debug("release key \"{}\" ({})", keyCode, KeyEvent.getKeyText(keyCode));
        handler.sendKeyRelease(keyCode);
        pressedKeys.remove((Integer) keyCode);
        e.consume();
    }

    // Forget, that the Windows key is pressed.
    if (keyCode == KeyEvent.VK_WINDOWS) {
        synchronized (Frame.this) {
            windowsKeyDown = false;
        }
    }
}
 
Example 17
Source File: InputHandler.java    From JavaGame with GNU Affero General Public License v3.0 4 votes vote down vote up
private void toggleKey(int keyCode, boolean isPressed) {
	if (!isIgnoreInput()) {
		if (keyCode == KeyEvent.VK_Z && isAzertyCountry || keyCode == KeyEvent.VK_W && !isAzertyCountry
				|| keyCode == KeyEvent.VK_UP) {
			up.toggle(isPressed);
		}

		if (keyCode == KeyEvent.VK_Q && isAzertyCountry || keyCode == KeyEvent.VK_A && !isAzertyCountry
				|| keyCode == KeyEvent.VK_LEFT) {
			left.toggle(isPressed);
		}

		if (keyCode == KeyEvent.VK_S || keyCode == KeyEvent.VK_DOWN) {
			down.toggle(isPressed);
		}

		if (keyCode == KeyEvent.VK_D || keyCode == KeyEvent.VK_RIGHT) {
			right.toggle(isPressed);
		}
	}
	if (isIgnoreInput()) {
		up.toggle(false);
		down.toggle(false);
		left.toggle(false);
		right.toggle(false);
	}

	if (keyCode == KeyEvent.VK_M) {
		if(!toggleMusic){
			Game.getBackgroundMusic().play();
			print.print("Playing Music", PrintTypes.MUSIC);
			toggleMusic = true;
		}
	}

	if (keyCode == KeyEvent.VK_COMMA) {
		Game.getBackgroundMusic().stop();
		if(toggleMusic)
			print.print("Stopping Music", PrintTypes.MUSIC);
			toggleMusic = false;
	}


	if (keyCode == KeyEvent.VK_W && isAzertyCountry || keyCode == KeyEvent.VK_Z && !isAzertyCountry) {
		// if (map == 0){
		// Game.getGame().setMap("/levels/water_level.png");
		// map++;
		// } else{
		// Game.getGame().setMap("/levels/custom_level.png");
		// map--;
		// }
		if (Game.getMap() == 2) {
			if (Game.isNpc()) {
				Game.setNpc(false);
			}
			Game.setChangeLevel(true);
		}
	}
	if (keyCode == KeyEvent.VK_N) {
		if (Game.getPlayer().isMoving()) {
			setIgnoreInput(true);
			int n = popup.Warn("Stop moving before spawning dummy AI");
			if (n == 0) {
				setIgnoreInput(false);
			}
			return;
		}
		if (!Game.isNpc()) {
			Game.setNpc(true);
			Game.npcSpawn();
			print.print("Dummy has been spawned", PrintTypes.GAME);
		}
	}
	if (keyCode == KeyEvent.VK_K) {
		if (Game.isNpc()) {
			Game.setNpc(false);
			Game.npcKill();
			print.print("Dummy has been removed", PrintTypes.GAME);
		}
	}

	if (keyCode == KeyEvent.VK_A && isAzertyCountry || keyCode == KeyEvent.VK_Q && !isAzertyCountry)
		this.quitGame();

	if (keyCode == KeyEvent.VK_BACK_QUOTE) {
		if (!Game.isClosing() && !Game.isDevMode()) {
			Game.setDevMode(true);
			new Thread(new SleepThread());
		}
	}
}
 
Example 18
Source File: AutocompleteTextField.java    From pumpernickel with MIT License 4 votes vote down vote up
@Override
public void keyPressed(KeyEvent e) {
	if (e.getKeyCode() == KeyEvent.VK_ENTER) {
		if (popup.isShowing()) {
			model.setSuggestions(model.suggestions,
					model.indicatedIndex, model.indicatedIndex);
			popup.setVisible(false);
			return;
		}
		int length = getText().length();
		setSelectionStart(length);
		setSelectionEnd(length);
		e.consume();
	} else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
		if (popup.isShowing()) {
			if (cycleIndicatedSuggestionForward())
				e.consume();
		} else {
			if (suggestionModel != null)
				suggestionModel.refreshSuggestions(model,
						AutocompleteTextField.this);
			if (cycleIndicatedSuggestionForward()) {
				e.consume();
			} else if (model.suggestions.length > 0) {
				showPopup();
				e.consume();
			}
		}
	} else if (e.getKeyCode() == KeyEvent.VK_UP) {
		if (popup.isShowing()) {
			if (cycleIndicatedSuggestionBackward())
				e.consume();
		} else {
			if (suggestionModel != null)
				suggestionModel.refreshSuggestions(model,
						AutocompleteTextField.this);
			if (cycleIndicatedSuggestionBackward())
				e.consume();
		}
	}
	if ((!e.isConsumed()) && popup.isShowing()) {
		popup.setVisible(false);
		e.consume();
	}
}
 
Example 19
Source File: ActionUtils.java    From workcraft with MIT License 4 votes vote down vote up
public static String getKeyString(int keyCode) {
    // Letters and numbers
    if (((keyCode >= KeyEvent.VK_0) && (keyCode <= KeyEvent.VK_9))
            || ((keyCode >= KeyEvent.VK_A) && (keyCode <= KeyEvent.VK_Z))) {
        return String.valueOf((char) keyCode);
    }
    switch (keyCode) {
    // Navigation keys
    case KeyEvent.VK_LEFT: return "Left";
    case KeyEvent.VK_UP: return "Up";
    case KeyEvent.VK_RIGHT: return "Right";
    case KeyEvent.VK_DOWN: return "Down";
    // Extra navigation keys
    case KeyEvent.VK_INSERT: return "Insert";
    case KeyEvent.VK_DELETE: return "Delete";
    case KeyEvent.VK_END: return "End";
    case KeyEvent.VK_HOME: return "Home";
    case KeyEvent.VK_PAGE_UP: return "PgUp";
    case KeyEvent.VK_PAGE_DOWN: return "PgDn";
    // Function keys
    case KeyEvent.VK_F1: return "F1";
    case KeyEvent.VK_F2: return "F2";
    case KeyEvent.VK_F3: return "F3";
    case KeyEvent.VK_F4: return "F4";
    case KeyEvent.VK_F5: return "F5";
    case KeyEvent.VK_F6: return "F6";
    case KeyEvent.VK_F7: return "F7";
    case KeyEvent.VK_F8: return "F8";
    case KeyEvent.VK_F9: return "F9";
    case KeyEvent.VK_F10: return "F10";
    case KeyEvent.VK_F11: return "F11";
    case KeyEvent.VK_F12: return "F12";
    // Symbols
    case KeyEvent.VK_EXCLAMATION_MARK: return "!";
    case KeyEvent.VK_QUOTEDBL: return "\"";
    case KeyEvent.VK_EURO_SIGN: return "€";
    case KeyEvent.VK_DOLLAR: return "$";
    case KeyEvent.VK_CIRCUMFLEX: return "^";
    case KeyEvent.VK_AMPERSAND: return "&";
    case KeyEvent.VK_ASTERISK: return "*";
    case KeyEvent.VK_UNDERSCORE: return "_";
    case KeyEvent.VK_MINUS: return "-";
    case KeyEvent.VK_PLUS: return "+";
    case KeyEvent.VK_EQUALS: return "=";
    case KeyEvent.VK_AT: return "@";
    case KeyEvent.VK_NUMBER_SIGN: return "#";
    case KeyEvent.VK_COLON: return ":";
    case KeyEvent.VK_SEMICOLON: return ";";
    case KeyEvent.VK_COMMA: return ",";
    case KeyEvent.VK_PERIOD: return ".";
    case KeyEvent.VK_SLASH: return "/";
    case KeyEvent.VK_BACK_SLASH: return "\\";
    case KeyEvent.VK_DEAD_TILDE: return "~";
    // Parenthesis and brackets
    case KeyEvent.VK_LEFT_PARENTHESIS: return "(";
    case KeyEvent.VK_RIGHT_PARENTHESIS: return ")";
    case KeyEvent.VK_OPEN_BRACKET: return "[";
    case KeyEvent.VK_CLOSE_BRACKET: return "]";
    case KeyEvent.VK_BRACELEFT: return "{";
    case KeyEvent.VK_BRACERIGHT: return "}";
    case KeyEvent.VK_LESS: return "<";
    case KeyEvent.VK_GREATER: return ">";
    // Formatting keys
    case KeyEvent.VK_SPACE: return "Space";
    case KeyEvent.VK_TAB: return "Tab";
    case KeyEvent.VK_ENTER: return "Enter";
    case KeyEvent.VK_BACK_SPACE: return "Backspace";
    case KeyEvent.VK_ESCAPE: return "Esc";
    }
    return "0x" + Integer.toString(keyCode, 16);
}
 
Example 20
Source File: MacKeymapUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static String getKeyText(int code) {
  switch (code) {
    case KeyEvent.VK_BACK_SPACE:     return BACKSPACE;
    case KeyEvent.VK_ESCAPE:         return ESCAPE;
    case KeyEvent.VK_CAPS_LOCK:      return CAPS_LOCK;
    case KeyEvent.VK_TAB:            return TAB;
    case KeyEvent.VK_SPACE:          return SPACE;
    case KeyEvent.VK_DELETE:         return DELETE;
    case KeyEvent.VK_HOME:           return HOME;
    case KeyEvent.VK_END:            return END;
    case KeyEvent.VK_PAGE_UP:        return PAGE_UP;
    case KeyEvent.VK_PAGE_DOWN:      return PAGE_DOWN;
    case KeyEvent.VK_UP:             return UP;
    case KeyEvent.VK_DOWN:           return DOWN;
    case KeyEvent.VK_LEFT:           return LEFT;
    case KeyEvent.VK_RIGHT:          return RIGHT;
    case KeyEvent.VK_NUM_LOCK:       return NUMBER_LOCK;
    case KeyEvent.VK_ENTER:          return RETURN;
    case KeyEvent.VK_BACK_QUOTE:     return "`";
    case KeyEvent.VK_NUMBER_SIGN:    return NUM_PAD;
    case KeyEvent.VK_MULTIPLY:       return NUM_PAD + " *";
    case KeyEvent.VK_ADD:            return "+";
    case KeyEvent.VK_SEPARATOR:      return ",";
    case KeyEvent.VK_SUBTRACT:       return "-";
    case KeyEvent.VK_DECIMAL:        return ".";
    case KeyEvent.VK_DIVIDE:         return "/";
    case KeyEvent.VK_NUMPAD0:        return "0";
    case KeyEvent.VK_NUMPAD1:        return "1";
    case KeyEvent.VK_NUMPAD2:        return "2";
    case KeyEvent.VK_NUMPAD3:        return "3";
    case KeyEvent.VK_NUMPAD4:        return "4";
    case KeyEvent.VK_NUMPAD5:        return "5";
    case KeyEvent.VK_NUMPAD6:        return "6";
    case KeyEvent.VK_NUMPAD7:        return "7";
    case KeyEvent.VK_NUMPAD8:        return "8";
    case KeyEvent.VK_NUMPAD9:        return "9";
    case KeyEvent.VK_SLASH:          return "/";
    case KeyEvent.VK_BACK_SLASH:     return "\\";
    case KeyEvent.VK_PERIOD:         return ".";
    case KeyEvent.VK_SEMICOLON:      return ";";
    case KeyEvent.VK_CLOSE_BRACKET:  return "]";
    case KeyEvent.VK_OPEN_BRACKET:   return "[";
    case KeyEvent.VK_EQUALS:         return "=";
    case KeyEvent.VK_MINUS:          return "-";
    case KeyEvent.VK_PLUS:           return "+";
    case 0:                          return "fn";
  }
  return KeyEvent.getKeyText(code);
}