diff --git a/frontend/components/editor/generate.tsx b/frontend/components/editor/generate.tsx index aef3c33..6366ba4 100644 --- a/frontend/components/editor/generate.tsx +++ b/frontend/components/editor/generate.tsx @@ -93,6 +93,17 @@ export default function GenerateInput({ } }, [code]) + useEffect(() => { + //listen to when Esc key is pressed and close the modal + const handleKeyDown = (e: KeyboardEvent) => { + if (e.key === "Escape") { + onClose() + } + } + window.addEventListener("keydown", handleKeyDown) + return () => window.removeEventListener("keydown", handleKeyDown) + }, []) + return (