# 12.18 Let Enter confirm and Esc close a layer

> Chapter 12, Pointer and keyboard. Section: Keyboard. Guide: https://www.designguide.dev/md/12-pointer-and-keyboard.md#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](https://www.designguide.dev/r/protect-unsaved-work-on-close-and-reload.md)).

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

**See:** [13.13 Protect unsaved work on close and reload](https://www.designguide.dev/r/protect-unsaved-work-on-close-and-reload.md)
