can anyone please help me understand why we are registering ENTER shortcut twice in this recepie

https://cookbook.vaadin.com/dialog-with-keyboard-shortcuts

can anyone please help me understand why we are registering ENTER shortcut twice in this recepie

The first one sets Enter as shortcut on the OK button, which triggers the button. The second one registers an Enter-shortcut, that does nothing, on the layout containing ALL buttons. That is done apparently to prevent Enter from triggering the OK button when other buttons (i.e. cancel) are focused.

Honestly, I think It’s a stupid solution. Frankly the entire recipe is stupid.

You should instead set default focus to the OK button. That way Enter will trigger it, unless you move focus to another button, i.e. the same behavior as in the recipe but without stupid.

yes exactly, I found it weird. Thanks for the suggestion.