本文整理汇总了Java中javafx.scene.input.KeyCode.getKeyCode方法的典型用法代码示例。如果您正苦于以下问题:Java KeyCode.getKeyCode方法的具体用法?Java KeyCode.getKeyCode怎么用?Java KeyCode.getKeyCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.input.KeyCode
的用法示例。
在下文中一共展示了KeyCode.getKeyCode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dispatchKeyEvent
import javafx.scene.input.KeyCode; //导入方法依赖的package包/类
@SuppressWarnings("deprecation") private void dispatchKeyEvent(final Node node, JavaAgentKeys keyToPress,
EventType<KeyEvent> eventType, char c) {
ensureVisible(node);
if (keyToPress == null) {
KeyboardMap kbMap = new KeyboardMap(c);
KeyCode keyCode = KeyCode.getKeyCode((kbMap.getChar() + "").toUpperCase());
if (eventType.getName().equals("KEY_TYPED")) {
keyCode = KeyCode.UNDEFINED;
}
int modifiersEx = deviceState.getModifierEx();
char char1 = kbMap.getChar();
if (modifiersEx == 0) {
modifiersEx = kbMap.getModifiersEx();
dispatchEvent(new KeyEvent(eventType, char1 + "", char1 + "", keyCode, deviceState.isShiftPressed(),
deviceState.isCtrlPressed(), deviceState.isAltPressed(), deviceState.isMetaPressed()), node);
} else {
dispatchEvent(new KeyEvent(eventType, char1 + "", char1 + "", keyCode, deviceState.isShiftPressed(),
deviceState.isCtrlPressed(), deviceState.isAltPressed(), deviceState.isMetaPressed()), node);
}
return;
}
final KeysMap keysMap = KeysMap.findMap(keyToPress);
if (keysMap == null) {
return;
}
deviceState.toggleKeyState(keyToPress);
dispatchEvent(new KeyEvent(eventType, KeyCode.UNDEFINED.impl_getChar(), KeyCode.UNDEFINED.impl_getChar(), keysMap.getCode(),
deviceState.isShiftPressed(), deviceState.isCtrlPressed(), deviceState.isAltPressed(), deviceState.isMetaPressed()),
node);
}