How to Prevent/Disable ESCAPE Key shortcut on Sub Windows


I create a
and add it via:

When pressing
and releasing
the ESCAPE key on my keyboard, the window automatically closes

Is there any way to disable this feature?

This issue actualluy creates a pretty severe bug on my app:

  1. User opens a sub-window with a form containing many fields to fill
  2. While filling the form, User chooses to upload a file
  3. The Native OS’s File Dialog shows on screen
  4. User regrests file upload, closing the dialog with
    the ESCAPE button
    - the File Dialog closes (OS behavior)
    release -
    the Vaadin Sub Window closes, and all of the form data is lost…

I don’t expect Vaadin to fix this issue so quickly - but just give us an easy option to disable ESCAPE on a specific sub-window

And more important:

Document this issue in ‘Book of Vaadin’


[/color]- for future developers.



Anyone from the Vaadin Team, please reply on this

It gets even more nasty:

  1. Open any Menu (MenuBar, ComboBox, NativeSelect, ContextMenu, etc)
  2. Press (and release) the ESCAPE key to close the menu [size=4]
  3. The menu is closed,
    and so is your window (!)
    , with all the information you just entered in its form

This is really something that should be addressed…

Just provide API to either disable the shortcut, or make it smart enough to detect that the ESCAPE just closed a menu

The same issue affects com.vaadin.ui.ComboBox placed on a subwindow,
closing opened combobox by ESC key closes the subwindow.

Any progress finding a workaround?


Good catch. Previously, you would have needed to call setCloseShortcut() to set a close shortcut and call removeCloseShortcut() to remove it.

I dug around a bit in the code, and found that a ESC had been hard-coded to close the window as part of adding WAI-ARIA support. I filed a ticket for this here

Please see the ticket for updates on progress.

As this is hardcoded in the client code, the only way you could get around it is to replace the VWindow implementation with your own fixed one and recompiling.

I don’t know if this issue is allready resolved, but possible workaround (version 7.3.8) works for me:

public class EscSafeWindow extends Window
    public EscSafeWindow()

        Button closeButton = new Button("Close");
        closeButton.addClickListener(event -> {

        setContent(new CssLayout(closeButton));

        addShortcutListener(new CloseShortcut(this, KeyCode.ESCAPE));