/** * Assert that all shift keys are in the expected state. * * @param event the event that was triggered */ private static void assertAllShiftKeys( Event event, boolean expectedCtrl, boolean expectedAlt, boolean expectedShift, boolean expectedMeta) { assertEquals("Expecting ctrl = " + expectedCtrl, expectedCtrl, event.getCtrlKey()); assertEquals("Expecting alt = " + expectedAlt, expectedAlt, event.getAltKey()); assertEquals("Expecting shift = " + expectedShift, expectedShift, event.getShiftKey()); assertEquals("Expecting meta = " + expectedMeta, expectedMeta, event.getMetaKey()); }
private static KeyEvent toKeyEvent(Event e) { Key key = KeyCodeMapper.getKey(e.getKeyCode()); Set<ModifierKey> modifiers = new HashSet<>(); if (e.getCtrlKey()) { modifiers.add(ModifierKey.CONTROL); } if (e.getAltKey()) { modifiers.add(ModifierKey.ALT); } if (e.getShiftKey()) { modifiers.add(ModifierKey.SHIFT); } if (e.getMetaKey()) { modifiers.add(ModifierKey.META); } return new KeyEvent(key, (char) e.getCharCode(), modifiers); }