Action

Escape Key

Detects and handles the Escape key press.

Installation

Get the action

npx lomer-ui action escape-key
Source code

Usage

Preview

Press escape key

Svelte Code

1
<script>
2
  import { escapeKey } from '$lib/actions/escape-key.svelte';
3
</script>
4

5
<div use:escapeKey={() => alert('^_^')}>
6
  <p>Press escape key</p>
7
</div>
8

Parameters

Parameter Type Description
callback (event: KeyboardEvent) => void Function triggered when Escape is pressed on the topmost element.