diff --git a/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/plugins/HeaderBarPlugin.java b/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/plugins/HeaderBarPlugin.java index b69561e84..83bbdddd2 100644 --- a/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/plugins/HeaderBarPlugin.java +++ b/domino-ui/src/main/java/org/dominokit/domino/ui/datatable/plugins/HeaderBarPlugin.java @@ -492,7 +492,7 @@ public SearchTableAction setAutoSearch(boolean autoSearch) { } textBox.addEventListener( - EventType.keypress.getName(), + EventType.keydown.getName(), evt -> { if (ElementUtil.isEnterKey(Js.uncheckedCast(evt))) { search(); diff --git a/domino-ui/src/main/java/org/dominokit/domino/ui/datepicker/DateBox.java b/domino-ui/src/main/java/org/dominokit/domino/ui/datepicker/DateBox.java index 600e493c3..4b8f0167d 100644 --- a/domino-ui/src/main/java/org/dominokit/domino/ui/datepicker/DateBox.java +++ b/domino-ui/src/main/java/org/dominokit/domino/ui/datepicker/DateBox.java @@ -180,7 +180,7 @@ private void initDateBox() { getInputElement() .addEventListener( - EventType.keypress.getName(), + EventType.keydown.getName(), evt -> { KeyboardEvent keyboardEvent = Js.cast(evt); if (isEnterKey(keyboardEvent) || isSpaceKey(keyboardEvent)) { diff --git a/domino-ui/src/main/java/org/dominokit/domino/ui/forms/FieldsGrouping.java b/domino-ui/src/main/java/org/dominokit/domino/ui/forms/FieldsGrouping.java index 6bccb28b2..31fa11ee9 100644 --- a/domino-ui/src/main/java/org/dominokit/domino/ui/forms/FieldsGrouping.java +++ b/domino-ui/src/main/java/org/dominokit/domino/ui/forms/FieldsGrouping.java @@ -314,6 +314,7 @@ public FieldsGrouping onKeyUp(KeyboardEventsHandler handler) { return this; } + @Deprecated public FieldsGrouping onKeyPress(KeyboardEventsHandler handler) { HTMLElement[] elements = getInputElements(); handler.accept(KeyboardEvents.listenOnKeyPress(elements)); diff --git a/domino-ui/src/main/java/org/dominokit/domino/ui/forms/NumberBox.java b/domino-ui/src/main/java/org/dominokit/domino/ui/forms/NumberBox.java index a670462d1..129d79c21 100644 --- a/domino-ui/src/main/java/org/dominokit/domino/ui/forms/NumberBox.java +++ b/domino-ui/src/main/java/org/dominokit/domino/ui/forms/NumberBox.java @@ -62,7 +62,7 @@ public NumberBox(String label) { setAutoValidation(true); enableFormatting(); - getInputElement().addEventListener(EventType.keypress, this::onKeyPress); + getInputElement().addEventListener(EventType.keydown, this::onKeyDown); getInputElement().addEventListener(EventType.paste, this::onPaste); } @@ -114,7 +114,7 @@ protected String createKeyMatch() { return sB.toString(); } - protected void onKeyPress(Event event) { + protected void onKeyDown(Event event) { KeyboardEvent keyboardEvent = Js.uncheckedCast(event); if (!keyboardEvent.key.matches(createKeyMatch())) event.preventDefault(); } diff --git a/domino-ui/src/main/java/org/dominokit/domino/ui/forms/ValueBox.java b/domino-ui/src/main/java/org/dominokit/domino/ui/forms/ValueBox.java index 575ce933c..e1fa0da8e 100644 --- a/domino-ui/src/main/java/org/dominokit/domino/ui/forms/ValueBox.java +++ b/domino-ui/src/main/java/org/dominokit/domino/ui/forms/ValueBox.java @@ -173,7 +173,7 @@ public ValueBox(String type, String label) { } protected void onEnterKey() { - listenOnKeyPress(getInputElement().element()) + listenOnKeyDown(getInputElement().element()) .onEnter( evt -> { if (DominoUIConfig.INSTANCE.isFocusNextFieldOnEnter()) { diff --git a/domino-ui/src/main/java/org/dominokit/domino/ui/keyboard/KeyboardEvents.java b/domino-ui/src/main/java/org/dominokit/domino/ui/keyboard/KeyboardEvents.java index 8c018c1aa..9c678dc51 100644 --- a/domino-ui/src/main/java/org/dominokit/domino/ui/keyboard/KeyboardEvents.java +++ b/domino-ui/src/main/java/org/dominokit/domino/ui/keyboard/KeyboardEvents.java @@ -39,7 +39,13 @@ public class KeyboardEvents { public static final String ESCAPE = "escape"; public static final String KEYDOWN = "keydown"; public static final String KEYUP = "keyup"; - public static final String KEYPRESS = "keypress"; + /** + * @deprecated use keydown instead. + * @see Element: keypress + * event MDN Web Docs (div element) + */ + @Deprecated public static final String KEYPRESS = "keypress"; + public static final String ARROWDOWN = "arrowdown"; public static final String ARROWUP = "arrowup"; public static final String ENTER = "enter"; @@ -113,8 +119,7 @@ public KeyboardEvents(List elements) { * @param elements the target elements * @param the type of the element * @return new instance - * @deprecated use {@link #listenOnKeyDown(Node...)}, {@link #listenOnKeyUp(Node...)}, {@link - * #listenOnKeyPress(Node...)} + * @deprecated use {@link #listenOnKeyDown(Node...)}, {@link #listenOnKeyUp(Node...)} */ @Deprecated public static KeyboardEvents listenOn(T... elements) { @@ -127,8 +132,7 @@ public static KeyboardEvents listenOn(T... elements) { * @param elements the target {@link IsElement} * @param the type of the element * @return new instance - * @deprecated use {@link #listenOnKeyDown(IsElement...)}, {@link #listenOnKeyUp(IsElement...)}, - * {@link #listenOnKeyPress(IsElement...)} + * @deprecated use {@link #listenOnKeyDown(IsElement...)}, {@link #listenOnKeyUp(IsElement...)} */ @Deprecated public static KeyboardEvents listenOn(IsElement... elements) { @@ -221,7 +225,11 @@ public static KeyboardEvents listenOnKeyUp( * @param elements the target element * @param the type of the element * @return new instance + * @deprecated use keydown instead. + * @see Element: keypress + * event MDN Web Docs (div element) */ + @Deprecated @SuppressWarnings("unchecked") public static KeyboardEvents listenOnKeyPress(T... elements) { return new KeyboardEvents<>(KEYPRESS, elements); @@ -233,7 +241,11 @@ public static KeyboardEvents listenOnKeyPress(T... elements) * @param elements the target {@link IsElement} * @param the type of the element * @return new instance + * @deprecated use keydown instead. + * @see Element: keypress + * event MDN Web Docs (div element) */ + @Deprecated @SuppressWarnings("unchecked") public static KeyboardEvents listenOnKeyPress( IsElement... elements) { @@ -247,7 +259,11 @@ public static KeyboardEvents listenOnKeyPress( * @param elements the target {@link IsElement} * @param the type of the element * @return new instance + * @deprecated use keydown instead. + * @see Element: keypress + * event MDN Web Docs (div element) */ + @Deprecated @SuppressWarnings("unchecked") public static KeyboardEvents listenOnKeyPress( List> elements) { diff --git a/domino-ui/src/main/java/org/dominokit/domino/ui/modals/ModalBackDrop.java b/domino-ui/src/main/java/org/dominokit/domino/ui/modals/ModalBackDrop.java index 2a2e3084d..1f161e0ca 100644 --- a/domino-ui/src/main/java/org/dominokit/domino/ui/modals/ModalBackDrop.java +++ b/domino-ui/src/main/java/org/dominokit/domino/ui/modals/ModalBackDrop.java @@ -62,7 +62,7 @@ private ModalBackDrop() { } }) .addEventListener( - EventType.keypress, + EventType.keydown, event -> { if (element.isEqualNode(Js.uncheckedCast(event.target))) { closeCurrentOpen(); diff --git a/domino-ui/src/main/java/org/dominokit/domino/ui/search/Search.java b/domino-ui/src/main/java/org/dominokit/domino/ui/search/Search.java index 1c98eb48d..d7b4de1b3 100644 --- a/domino-ui/src/main/java/org/dominokit/domino/ui/search/Search.java +++ b/domino-ui/src/main/java/org/dominokit/domino/ui/search/Search.java @@ -98,7 +98,7 @@ public void run() { } searchInput.addEventListener( - EventType.keypress.getName(), + EventType.keydown.getName(), evt -> { if (ElementUtil.isEnterKey(Js.uncheckedCast(evt))) { searchHandler.onSearch(searchInput.value); diff --git a/domino-ui/src/main/java/org/dominokit/domino/ui/search/SearchBox.java b/domino-ui/src/main/java/org/dominokit/domino/ui/search/SearchBox.java index fd776f468..69bd0527e 100644 --- a/domino-ui/src/main/java/org/dominokit/domino/ui/search/SearchBox.java +++ b/domino-ui/src/main/java/org/dominokit/domino/ui/search/SearchBox.java @@ -155,7 +155,7 @@ public SearchBox setAutoSearch(boolean autoSearch) { } textBox.addEventListener( - EventType.keypress.getName(), + EventType.keydown.getName(), evt -> { if (ElementUtil.isEnterKey(Js.uncheckedCast(evt))) { doSearch(); diff --git a/domino-ui/src/main/java/org/dominokit/domino/ui/utils/DelayedTextInput.java b/domino-ui/src/main/java/org/dominokit/domino/ui/utils/DelayedTextInput.java index dbe5f5a27..673a4be47 100644 --- a/domino-ui/src/main/java/org/dominokit/domino/ui/utils/DelayedTextInput.java +++ b/domino-ui/src/main/java/org/dominokit/domino/ui/utils/DelayedTextInput.java @@ -110,7 +110,7 @@ public void run() { }); inputElement.addEventListener( - EventType.keypress.getName(), + EventType.keydown.getName(), evt -> { if (ElementUtil.isEnterKey(Js.uncheckedCast(evt))) { DelayedTextInput.this.onEnterAction.doAction(); diff --git a/domino-ui/src/main/java/org/dominokit/domino/ui/utils/ElementUtil.java b/domino-ui/src/main/java/org/dominokit/domino/ui/utils/ElementUtil.java index 1caf1446c..d2abf438f 100644 --- a/domino-ui/src/main/java/org/dominokit/domino/ui/utils/ElementUtil.java +++ b/domino-ui/src/main/java/org/dominokit/domino/ui/utils/ElementUtil.java @@ -138,7 +138,7 @@ public static boolean isEscapeKey(KeyboardEvent keyboardEvent) { * will be called only once, if the element is appended more than once a new callback should be * registered. * - * @param element the {@link HTMLElement} which is going to be added to the body + * @param element the {@link HTMLElementvirt} which is going to be added to the body * @param callback {@link ObserverCallback} * @return an Optional {@link ElementObserver} */ @@ -214,7 +214,7 @@ public static T numbersOnly(T hasInputElement) { hasInputElement .getInputElement() .addEventListener( - "keypress", + "keydown", evt -> { KeyboardEvent keyboardEvent = Js.uncheckedCast(evt); if (!(isMinusKey(keyboardEvent.key) || keyboardEvent.key.matches("^\\d+$"))) { @@ -247,7 +247,7 @@ public static T decimalOnly(T hasInputElement) { hasInputElement .getInputElement() .addEventListener( - "keypress", + "keydown", evt -> { KeyboardEvent keyboardEvent = Js.uncheckedCast(evt); String key = keyboardEvent.key;