public static boolean dispatchKeyType(Event e, Handler<KeyEvent> handler) { final KeyEvent event = EventTranslator.toKeyEvent(e); if (e.getCharCode() == 0) return true; if (e.getCharCode() == '\n') return true; if (e.getCharCode() == '\r') return true; if (event.has(ModifierKey.META) || event.has(ModifierKey.ALT) || event.has(ModifierKey.CONTROL)) return true; handler.handle(event); return !event.isConsumed(); }
public static boolean dispatchKeyRelease(Event e, Handler<KeyEvent> handler) { final KeyEvent event = EventTranslator.toKeyEvent(e); handler.handle(event); return !event.isConsumed(); }
public static boolean dispatchKeyPress(Event e, Handler<KeyEvent> handler) { final KeyEvent event = EventTranslator.toKeyEvent(e); handler.handle(event); // disable back button if (event.getKey() == Key.BACKSPACE) return false; // disable navigation keys to prevent browser scrolling if (event.getKey() == Key.UP || event.getKey() == Key.DOWN || event.getKey() == Key.LEFT || event.getKey() == Key.RIGHT) return false; // disable space scrolling in case of unhandled space if (event.getKey() == Key.SPACE) return false; // disable shift+arrow selection if (event.is(KeyStrokeSpecs.SELECT_BEFORE) || event.is(KeyStrokeSpecs.SELECT_AFTER)) return false; // disable back forward with Ctrl/Cmd + [ / ] if (event.is(KeyStrokeSpecs.MATCHING_CONSTRUCTS)) return false; // disable tab navigation if (event.is(Key.TAB) || event.is(Key.TAB, ModifierKey.SHIFT)) return false; return !event.isConsumed(); }