当前位置: 首页>>代码示例>>Java>>正文


Java KeyEvent.VK_KP_UP属性代码示例

本文整理汇总了Java中java.awt.event.KeyEvent.VK_KP_UP属性的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.VK_KP_UP属性的具体用法?Java KeyEvent.VK_KP_UP怎么用?Java KeyEvent.VK_KP_UP使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在java.awt.event.KeyEvent的用法示例。


在下文中一共展示了KeyEvent.VK_KP_UP属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getKeyText

/** @return slight modification of what KeyEvent.getKeyText() returns.
 *  The numpad Left, Right, Down, Up get extra result.
 */
private static String getKeyText(int keyCode) {
    String ret = KeyEvent.getKeyText(keyCode);
    if (ret != null) {
        switch (keyCode) {
            case KeyEvent.VK_KP_DOWN:
                ret = prefixNumpad(ret, KeyEvent.VK_DOWN);
                break;
            case KeyEvent.VK_KP_LEFT:
                ret = prefixNumpad(ret, KeyEvent.VK_LEFT);
                break;
            case KeyEvent.VK_KP_RIGHT:
                ret = prefixNumpad(ret, KeyEvent.VK_RIGHT);
                break;
            case KeyEvent.VK_KP_UP:
                ret = prefixNumpad(ret, KeyEvent.VK_UP);
                break;
        }
    }
    return ret;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:Utilities.java

示例2: keyPressed

@Override
public void keyPressed(KeyEvent e) {
	int key = e.getKeyCode();
	//System.out.println("human pressed " + key);
	
	if (key == KeyEvent.VK_UP || key == KeyEvent.VK_KP_UP) {
		// UP means accelerate forward
		lastKeyPressed = HumanKeyPressed.UP;
		//System.out.println("human pressed UP ");
	} else if (key == KeyEvent.VK_DOWN || key == KeyEvent.VK_KP_DOWN) {
		// DOWN means decelerate
		lastKeyPressed = HumanKeyPressed.DOWN;
	} else if (key == KeyEvent.VK_RIGHT || key == KeyEvent.VK_KP_RIGHT) {
		// turn RIGHT
		lastKeyPressed = HumanKeyPressed.RIGHT;
	} else if (key == KeyEvent.VK_LEFT || key == KeyEvent.VK_KP_LEFT) {
		// turn LEFT
		lastKeyPressed = HumanKeyPressed.LEFT;
	} else if (key == KeyEvent.VK_SPACE) {
		// fire
		lastKeyPressed = HumanKeyPressed.FIRE;
	}
	
	if (lastKeyPressed != null) {
		lastMouseClick = null;
	}
}
 
开发者ID:amymcgovern,项目名称:spacesettlers,代码行数:27,代码来源:HumanTeamClient.java

示例3: dispatchKeyEvent

@Override
public boolean dispatchKeyEvent(KeyEvent e) {
	if(!Menu.menu.isVisible()){
		if(e.getID() == KeyEvent.KEY_PRESSED){
			int d = e.isShiftDown() ? 3 : e.isControlDown() ? 2 : 1;
			switch(e.getKeyCode()){
			case KeyEvent.VK_LEFT:
			case KeyEvent.VK_KP_LEFT:
				e.getComponent().getLocation(tmp);
				e.getComponent().setLocation(tmp.x - d, tmp.y);
				break;
			case KeyEvent.VK_RIGHT:
			case KeyEvent.VK_KP_RIGHT:
				e.getComponent().getLocation(tmp);
				e.getComponent().setLocation(tmp.x + d, tmp.y);
				break;
			case KeyEvent.VK_UP:
			case KeyEvent.VK_KP_UP:
				e.getComponent().getLocation(tmp);
				e.getComponent().setLocation(tmp.x, tmp.y - d);
				break;
			case KeyEvent.VK_DOWN:
			case KeyEvent.VK_KP_DOWN:
				e.getComponent().getLocation(tmp);
				e.getComponent().setLocation(tmp.x, tmp.y + d);
				break;
			}
		}
	}
	return false;
}
 
开发者ID:RoanH,项目名称:KeysPerSecond,代码行数:31,代码来源:Listener.java


注:本文中的java.awt.event.KeyEvent.VK_KP_UP属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。