> ## Documentation Index
> Fetch the complete documentation index at: https://docs.overflow.co/llms.txt
> Use this file to discover all available pages before exploring further.

# onEscapeKeyPressed

> Fires when the shopper presses the Escape key while an element (or its sub-fields) has focus.

`onEscapeKeyPressed` fires when the shopper presses the literal Escape key while the element (or one of its sub-fields) has focus. Use it to close your own modals, blur the input, or restore prior UI state.

## Payload

```typescript theme={null}
type OverflowEscapeKeyPressedEvent<T> = { elementType: T };
```

The key is always Escape by definition, so the payload carries only `elementType`.

## Example

```javascript theme={null}
overflow.email()
  .on('onEscapeKeyPressed', () => {
    modal.close();
  })
  .mount('#email');
```

## The SDK does not `preventDefault()`

Default browser behavior (for example, dismissing a native autofill panel) is preserved. Merchants own the response.

## Not emitted by wallets or `submitButton`

`applePay`, `googlePay`, and `submitButton` do not emit this event. The event key is omitted from their event map, so subscribing is a TypeScript error and a runtime no-op (with a console warning).

* Wallets render inside their own rendering surface, whose native payment sheet captures keystrokes once open.
* `submitButton` has no shopper-dismissable input.

To react to a shopper abandoning a wallet sheet, subscribe to [`onExit`](/payment-elements/events/on-exit) instead.

## Per-element wiring

* **Single-input elements** (`email`, `phone`) attach the key listener directly to the input.
* **Multi-input elements** (`fullName`, `billingAddress`, `shippingAddress`, manual-mode `bank`, `checkout`) attach the listener to the wrapper element and let the keystroke bubble from whichever sub-field had focus. The event fires once per keypress regardless of which sub-field was active.
* **`bank`** fires only in manual mode. Address-lookup mode is a launch button to an external modal whose keyboard handling is out of the SDK's reach.

## Coverage gap on `card`

Card secured fields (card number, expiration, security code) own keystrokes inside their own rendering surface, which does not expose an Escape callback. Coverage is best-effort:

* Pressing Escape inside the holder-name or postal-code inputs fires the event.
* Pressing Escape inside one of the secured card fields does not.

## See also

* [`onFocus` and `onBlur`](/payment-elements/events/on-focus-blur)
* [`onExit`](/payment-elements/events/on-exit)
