# Close on Escape
Allows for an ordered stack of components that carry out an action when the esc key is pressed. Each instance will carry out their `onEscape` action before being removed from the stack on a first-in-last-out basis.
This is useful for components such as `` and ``, particularly in flows that see multiple `Dialog`s that 'stack'.
## Usage
To use this component, either nest it inside of an existing component or as a sibling, passing it a function as `onEscape` to be called when esc is pressed.
```jsx
import CloseOnEscape from 'calypso/components/close-on-escape';
function closeDialog() {
// Take care of closing this component
}
function render() {
// Nested:
return (
);
// Or as a sibling:
/*
return (
);
*/
}
```
## Props
### `onEscape`
| Type | function |
| Required | No |
| Default | noop |
The function to be called when esc is pressed.