diff --git a/src/lib/components/chat/MessageInput.svelte b/src/lib/components/chat/MessageInput.svelte index a23649d8b..eff65a254 100644 --- a/src/lib/components/chat/MessageInput.svelte +++ b/src/lib/components/chat/MessageInput.svelte @@ -295,6 +295,13 @@ const dropZone = document.querySelector('body'); + const handleKeyDown = (event: KeyboardEvent) => { + if (event.key === 'Escape') { + console.log('Escape'); + dragged = false; + } + }; + const onDragOver = (e) => { e.preventDefault(); dragged = true; @@ -350,11 +357,15 @@ dragged = false; }; + window.addEventListener('keydown', handleKeyDown); + dropZone?.addEventListener('dragover', onDragOver); dropZone?.addEventListener('drop', onDrop); dropZone?.addEventListener('dragleave', onDragLeave); return () => { + window.removeEventListener('keydown', handleKeyDown); + dropZone?.removeEventListener('dragover', onDragOver); dropZone?.removeEventListener('drop', onDrop); dropZone?.removeEventListener('dragleave', onDragLeave);