com.vaadin.flow.component.ClickNotifier.addClickShortcut(...) not working as expected

Hi all! I have the following code:

loginButton = new Button(); loginButton.setText("Login"); loginButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY, ButtonVariant.LUMO_SUCCESS); loginButton.setIcon(VaadinIcon.SIGN_IN.create()); loginButton.addClickShortcut(Key.ENTER); loginButton.addClickShortcut(Key.NUMPAD_ENTER); loginButton.addClickListener(loginButtonClickEvent -> fireEvent(new LoginEvent(this, binder.getBean())) ); add(loginButton);

As you can see, I added two keyboard shortcuts - for Enter and for Numpad Enter. The problem is that when I press Enter, the LoginEvent is fired once (which is logical and expected), but when I press Numpad Enter, the LoginEvent is fired twice already (which is not logical and not expected). Moreover, in order to solve the problem, it is enough to remove any of the keyboard shortcuts - and then Enter (if I leave it, but remove Numpad Enter) fire the event once, and Numpad Enter (if I leave it, but remove Enter) fire the event once. Q: Am I doing something wrong, or is this a bug?

I also noticed that even if I leave only Enter, Numpad Enter still fire the event.

Welcome in the JavaScript / Keyboard Hell. Normally Enter as shortcut is enough, don’t overthink it.

…but if I leave only Numpad Enter, then just Enter will no longer fire the event.


That’s why we use flow :sunglasses: