Java Code Examples for javafx.scene.input.KeyCode#getKeyCode()
The following examples show how to use
javafx.scene.input.KeyCode#getKeyCode() .
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: MarioFactory.java From FXGLGames with MIT License | 6 votes |
@Spawns("keyCode") public Entity newKeyCode(SpawnData data) { String key = data.get("key"); KeyCode keyCode = KeyCode.getKeyCode(key); var lift = new LiftComponent(); lift.setGoingUp(true); lift.yAxisDistanceDuration(6, Duration.seconds(0.76)); return entityBuilder(data) .view(new KeyView(keyCode, Color.YELLOW, 24)) .with(lift) .zIndex(100) .build(); }
Example 2
Source File: Dm3270Context.java From xframium-java with GNU General Public License v3.0 | 6 votes |
private static KeyCode findKeyCode(char character) { if (KEY_CODES.containsKey(character)) { return (KeyCode) KEY_CODES.get(character); } KeyCode keyCode = KeyCode.getKeyCode(String.valueOf(Character .toUpperCase(character))); if (keyCode != null) { return keyCode; } for (KeyCode code : KeyCode.values()) { if ((char) code.impl_getCode() == character) { return code; } } throw new IllegalArgumentException("No KeyCode found for character: " + character); }
Example 3
Source File: MarioFactory.java From FXGLGames with MIT License | 6 votes |
@Spawns("keyCode") public Entity newKeyCode(SpawnData data) { String key = data.get("key"); KeyCode keyCode = KeyCode.getKeyCode(key); var lift = new LiftComponent(); lift.setGoingUp(true); lift.yAxisDistanceDuration(6, Duration.seconds(0.76)); return entityBuilder(data) .view(new KeyView(keyCode, Color.YELLOW, 24)) .with(lift) .zIndex(100) .build(); }
Example 4
Source File: FXEventQueueDevice.java From marathonv5 with Apache License 2.0 | 5 votes |
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, JavaCompatibility.getChar(KeyCode.UNDEFINED), JavaCompatibility.getChar(KeyCode.UNDEFINED), keysMap.getCode(), deviceState.isShiftPressed(), deviceState.isCtrlPressed(), deviceState.isAltPressed(), deviceState.isMetaPressed()), node); }
Example 5
Source File: KeyHandler.java From jace with GNU General Public License v2.0 | 5 votes |
public KeyHandler(String comboText) { KeyCode testCode = KeyCode.getKeyCode(comboText); if (testCode != null) { key = testCode; } else { init(KeyCodeCombination.valueOf(comboText)); } }
Example 6
Source File: KeyCodeInfo.java From CPUSim with GNU General Public License v3.0 | 4 votes |
private KeyCodeCombination convert(String keyBinding) { KeyCodeCombination.ModifierValue shift = KeyCodeCombination.ModifierValue.UP; KeyCodeCombination.ModifierValue ctrl = KeyCodeCombination.ModifierValue.UP; KeyCodeCombination.ModifierValue alt = KeyCodeCombination.ModifierValue.UP; KeyCodeCombination.ModifierValue meta = KeyCodeCombination.ModifierValue.UP; KeyCodeCombination.ModifierValue shortcut = KeyCodeCombination .ModifierValue.UP; String[] keys = keyBinding.split("-"); KeyCode key = KeyCode.getKeyCode(keys[keys.length - 1]); if (key == null) { key = Convert.charToKeyCode(keys[keys.length - 1]); } keys[keys.length - 1] = null; if (keys.length > 1) { for (String mod : keys) { if (mod != null) { switch (mod) { case "Shift": shift = KeyCodeCombination.ModifierValue.DOWN; break; case "Ctrl": if (!System.getProperty("os.name").toLowerCase().contains("mac")) { shortcut = KeyCodeCombination.ModifierValue.DOWN; } else { ctrl = KeyCodeCombination.ModifierValue.DOWN; } break; case "Alt": alt = KeyCodeCombination.ModifierValue.DOWN; break; case "Meta": meta = KeyCodeCombination.ModifierValue.DOWN; break; case "Cmd": shortcut = KeyCodeCombination.ModifierValue.DOWN; break; default: break; } } } } if (key != null) return new KeyCodeCombination(key, shift, ctrl, alt, meta, shortcut); else return null; }