本文整理汇总了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;
}
示例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;
}
}
示例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;
}