close dialog by pressing mobile back button

Is there a way to close dialog if user presses back button on phone/tablet? For now, pressing back button changes the view behind but dialog remains open.

Thanks,
Markus

If your question is about Vaadin 13 and Flow, you are probably looking for something like this

Shortcuts.addShortcutListener(dialog, () -> dialog.close(), Key.BROWSER_BACK);