Let Enter confirm and Esc close a layer
Default
Rule. Let Enter run the default action, and let Esc cancel or close only the top layer.
Why. An Esc that closes the wrong layer, or none, traps a person who uses the keyboard.
- Close a popover before the dialog under it.
- Let Esc clear a typed search first, then close the layer.
- Keep a draft when Esc closes a form (Rule 13.13).
Figure. Esc closes the popover only. The page and the focus ring stay.