diff --git a/web/src/lib/utils/click-outside.ts b/web/src/lib/utils/click-outside.ts index dae9848626..e54ee8ef09 100644 --- a/web/src/lib/utils/click-outside.ts +++ b/web/src/lib/utils/click-outside.ts @@ -6,11 +6,19 @@ export function clickOutside(node: Node) { } }; + const handleKey = (event: KeyboardEvent) => { + if (event.key == 'Escape') { + node.dispatchEvent(new CustomEvent('outclick')); + } + }; + document.addEventListener('click', handleClick, true); + document.addEventListener('keydown', handleKey, true); return { destroy() { document.removeEventListener('click', handleClick, true); + document.removeEventListener('keydown', handleKey, true); } }; }