Close modals when Escape is pressed

This commit is contained in:
Dallas Hoffman 2023-09-24 00:21:31 -04:00
parent 5195700397
commit 7a7b40e2ba
1 changed files with 7 additions and 0 deletions

View File

@ -21,8 +21,15 @@
function close() {
open = false;
}
function escape(event: KeyboardEvent) {
if (event.key === 'Escape') {
close();
}
}
</script>
<svelte:window on:keyup={escape} />
<dialog {open} on:click={close} class="app-modal">
<article style:--max-width={maxWidths[size]} on:click|stopPropagation>
<header>