Close modals when Escape is pressed
This commit is contained in:
parent
5195700397
commit
7a7b40e2ba
|
@ -21,8 +21,15 @@
|
||||||
function close() {
|
function close() {
|
||||||
open = false;
|
open = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function escape(event: KeyboardEvent) {
|
||||||
|
if (event.key === 'Escape') {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<svelte:window on:keyup={escape} />
|
||||||
<dialog {open} on:click={close} class="app-modal">
|
<dialog {open} on:click={close} class="app-modal">
|
||||||
<article style:--max-width={maxWidths[size]} on:click|stopPropagation>
|
<article style:--max-width={maxWidths[size]} on:click|stopPropagation>
|
||||||
<header>
|
<header>
|
||||||
|
|
Loading…
Reference in New Issue