Generic Enter key shortcut listener

For Vaadin 8 I had a utility that essentially took a HasChildren (often a Layout), iterated throw the children and kept track of those that were Focusable and then used a generic ShortcutAction that handled focusing of components based on certain rules when the enter key was pressed. How would such a utility be written in Flow (12)? I noticed that e.g. TextFields could have key listeners but how to handle the generic case?

Thanks in advance,
Nik

Hi Nicklas,

Does this help?
https://vaadin.com/releases/vaadin-13#shortcuts-api

It’s for Vaadin 13, but shouldn’t be hard to change to this version.

Luis Gutierrez:
Hi Nicklas,

Does this help?
https://vaadin.com/releases/vaadin-13#shortcuts-api

It’s for Vaadin 13, but shouldn’t be hard to change to this version.

Thanks, it looks promising. Might as well jump to the 13-line since I’m prototyping for a new application…

Luis Gutierrez:
Hi Nicklas,

Does this help?
https://vaadin.com/releases/vaadin-13#shortcuts-api

It’s for Vaadin 13, but shouldn’t be hard to change to this version.

Hi, is the correct behavior, press shortcut key twice, then only login?

Shortcuts.addShortcutListener(loginPanel, loginBttn::click, Key.ENTER);

There’s a special case with using Enter as the shortcut key that also requires you to use .allowBrowserDefault() on the shortcut registration.