Rule 12.18, Pointer and keyboard

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.

Figure. Esc closes the popover only. The page and the focus ring stay.