本文整理汇总了Java中edu.umd.cs.piccolo.event.PInputEvent.getKeyCode方法的典型用法代码示例。如果您正苦于以下问题:Java PInputEvent.getKeyCode方法的具体用法?Java PInputEvent.getKeyCode怎么用?Java PInputEvent.getKeyCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.umd.cs.piccolo.event.PInputEvent
的用法示例。
在下文中一共展示了PInputEvent.getKeyCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: keyPressed
import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
/**
* Delete selection when delete key is pressed (if enabled).
*
* @param e the key press event
*/
public void keyPressed(final PInputEvent e) {
if (e.getKeyCode() == KeyEvent.VK_DELETE && deleteKeyActive) {
final Iterator selectionEn = selection.keySet().iterator();
while (selectionEn.hasNext()) {
final PNode node = (PNode) selectionEn.next();
node.removeFromParent();
}
selection.clear();
}
}
示例2: keyPressed
import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
/**
* Processes key pressed events.
*
* @param event event representing the key press
*/
public void keyPressed(final PInputEvent event) {
final PNode oldLocation = focusNode;
switch (event.getKeyCode()) {
case KeyEvent.VK_LEFT:
moveFocusLeft(event);
break;
case KeyEvent.VK_RIGHT:
moveFocusRight(event);
break;
case KeyEvent.VK_UP:
case KeyEvent.VK_PAGE_UP:
if (event.isAltDown()) {
moveFocusOut(event);
}
else {
moveFocusUp(event);
}
break;
case KeyEvent.VK_DOWN:
case KeyEvent.VK_PAGE_DOWN:
if (event.isAltDown()) {
moveFocusIn(event);
}
else {
moveFocusDown(event);
}
break;
default:
// Pressed key is not a navigation key.
}
if (focusNode != null && oldLocation != focusNode) {
directCameraViewToFocus(event.getCamera(), focusNode, NAVIGATION_DURATION);
}
}