@Test public void testKeyDownListenerWhenKeyUIsPressed() { event.key = "u"; event.ctrlKey = true; shortcuts.keyDownListener(event); verify(event).preventDefault(); verify(listShortcuts).onCtrlU(); }
void keyDownListener(final Event e) { if (!(e instanceof KeyboardEvent)) { return; } final KeyboardEvent event = (KeyboardEvent) e; if (isNotEnabled()) { return; } switch (event.key) { case "Esc": case "Escape": listShortcuts.onEscape(); return; case "Backspace": if (event.ctrlKey) { listShortcuts.onCtrlBackspace(); } return; case "Tab": if (isSearchBarTarget(event)) { event.preventDefault(); listShortcuts.onTab(); } return; case "s": if (event.ctrlKey) { event.preventDefault(); listShortcuts.onCtrlS(); } return; case "b": if (event.ctrlKey) { event.preventDefault(); listShortcuts.onCtrlB(); } return; case "u": if (event.ctrlKey) { event.preventDefault(); listShortcuts.onCtrlU(); } return; case "d": if (event.ctrlKey) { event.preventDefault(); listShortcuts.onCtrlD(); } return; case "e": if (event.ctrlKey) { event.preventDefault(); listShortcuts.onCtrlE(); } return; } if (isInputEvent(event) && !isSearchBarTarget(event)) { return; } switch (event.key) { case "Down": case "ArrowDown": listShortcuts.onArrowDown(); return; case "Up": case "ArrowUp": listShortcuts.onArrowUp(); return; case "Left": case "ArrowLeft": listShortcuts.onArrowLeft(); return; case "Right": case "ArrowRight": listShortcuts.onArrowRight(); } }
DataTypeShortcuts { void keyDownListener(final Event e) { if (!(e instanceof KeyboardEvent)) { return; } final KeyboardEvent event = (KeyboardEvent) e; if (isNotEnabled()) { return; } switch (event.key) { case "Esc": case "Escape": listShortcuts.onEscape(); return; case "Backspace": if (event.ctrlKey) { listShortcuts.onCtrlBackspace(); } return; case "Tab": if (isSearchBarTarget(event)) { event.preventDefault(); listShortcuts.onTab(); } return; case "s": if (event.ctrlKey) { event.preventDefault(); listShortcuts.onCtrlS(); } return; case "b": if (event.ctrlKey) { event.preventDefault(); listShortcuts.onCtrlB(); } return; case "u": if (event.ctrlKey) { event.preventDefault(); listShortcuts.onCtrlU(); } return; case "d": if (event.ctrlKey) { event.preventDefault(); listShortcuts.onCtrlD(); } return; case "e": if (event.ctrlKey) { event.preventDefault(); listShortcuts.onCtrlE(); } return; } if (isInputEvent(event) && !isSearchBarTarget(event)) { return; } switch (event.key) { case "Down": case "ArrowDown": listShortcuts.onArrowDown(); return; case "Up": case "ArrowUp": listShortcuts.onArrowUp(); return; case "Left": case "ArrowLeft": listShortcuts.onArrowLeft(); return; case "Right": case "ArrowRight": listShortcuts.onArrowRight(); } } }
DataTypeShortcuts { void keyDownListener(final Event e) { if (!(e instanceof KeyboardEvent)) { return; } final KeyboardEvent event = (KeyboardEvent) e; if (isNotEnabled()) { return; } switch (event.key) { case "Esc": case "Escape": listShortcuts.onEscape(); return; case "Backspace": if (event.ctrlKey) { listShortcuts.onCtrlBackspace(); } return; case "Tab": if (isSearchBarTarget(event)) { event.preventDefault(); listShortcuts.onTab(); } return; case "s": if (event.ctrlKey) { event.preventDefault(); listShortcuts.onCtrlS(); } return; case "b": if (event.ctrlKey) { event.preventDefault(); listShortcuts.onCtrlB(); } return; case "u": if (event.ctrlKey) { event.preventDefault(); listShortcuts.onCtrlU(); } return; case "d": if (event.ctrlKey) { event.preventDefault(); listShortcuts.onCtrlD(); } return; case "e": if (event.ctrlKey) { event.preventDefault(); listShortcuts.onCtrlE(); } return; } if (isInputEvent(event) && !isSearchBarTarget(event)) { return; } switch (event.key) { case "Down": case "ArrowDown": listShortcuts.onArrowDown(); return; case "Up": case "ArrowUp": listShortcuts.onArrowUp(); return; case "Left": case "ArrowLeft": listShortcuts.onArrowLeft(); return; case "Right": case "ArrowRight": listShortcuts.onArrowRight(); } } @Inject  DataTypeShortcuts(final DataTypeListShortcuts listShortcuts); }
DataTypeShortcuts { void keyDownListener(final Event e) { if (!(e instanceof KeyboardEvent)) { return; } final KeyboardEvent event = (KeyboardEvent) e; if (isNotEnabled()) { return; } switch (event.key) { case "Esc": case "Escape": listShortcuts.onEscape(); return; case "Backspace": if (event.ctrlKey) { listShortcuts.onCtrlBackspace(); } return; case "Tab": if (isSearchBarTarget(event)) { event.preventDefault(); listShortcuts.onTab(); } return; case "s": if (event.ctrlKey) { event.preventDefault(); listShortcuts.onCtrlS(); } return; case "b": if (event.ctrlKey) { event.preventDefault(); listShortcuts.onCtrlB(); } return; case "u": if (event.ctrlKey) { event.preventDefault(); listShortcuts.onCtrlU(); } return; case "d": if (event.ctrlKey) { event.preventDefault(); listShortcuts.onCtrlD(); } return; case "e": if (event.ctrlKey) { event.preventDefault(); listShortcuts.onCtrlE(); } return; } if (isInputEvent(event) && !isSearchBarTarget(event)) { return; } switch (event.key) { case "Down": case "ArrowDown": listShortcuts.onArrowDown(); return; case "Up": case "ArrowUp": listShortcuts.onArrowUp(); return; case "Left": case "ArrowLeft": listShortcuts.onArrowLeft(); return; case "Right": case "ArrowRight": listShortcuts.onArrowRight(); } } @Inject  DataTypeShortcuts(final DataTypeListShortcuts listShortcuts); void init(final DataTypeList dataTypeList); void setup(); void teardown(); void reset(); void highlight(final Element element); void enable(); void disable(); }
DataTypeShortcuts { void keyDownListener(final Event e) { if (!(e instanceof KeyboardEvent)) { return; } final KeyboardEvent event = (KeyboardEvent) e; if (isNotEnabled()) { return; } switch (event.key) { case "Esc": case "Escape": listShortcuts.onEscape(); return; case "Backspace": if (event.ctrlKey) { listShortcuts.onCtrlBackspace(); } return; case "Tab": if (isSearchBarTarget(event)) { event.preventDefault(); listShortcuts.onTab(); } return; case "s": if (event.ctrlKey) { event.preventDefault(); listShortcuts.onCtrlS(); } return; case "b": if (event.ctrlKey) { event.preventDefault(); listShortcuts.onCtrlB(); } return; case "u": if (event.ctrlKey) { event.preventDefault(); listShortcuts.onCtrlU(); } return; case "d": if (event.ctrlKey) { event.preventDefault(); listShortcuts.onCtrlD(); } return; case "e": if (event.ctrlKey) { event.preventDefault(); listShortcuts.onCtrlE(); } return; } if (isInputEvent(event) && !isSearchBarTarget(event)) { return; } switch (event.key) { case "Down": case "ArrowDown": listShortcuts.onArrowDown(); return; case "Up": case "ArrowUp": listShortcuts.onArrowUp(); return; case "Left": case "ArrowLeft": listShortcuts.onArrowLeft(); return; case "Right": case "ArrowRight": listShortcuts.onArrowRight(); } } @Inject  DataTypeShortcuts(final DataTypeListShortcuts listShortcuts); void init(final DataTypeList dataTypeList); void setup(); void teardown(); void reset(); void highlight(final Element element); void enable(); void disable();  }