From fac673c0480454c06784a7cec59a8cfbcc07c617 Mon Sep 17 00:00:00 2001 From: Lorraxs Date: Sat, 23 Mar 2024 10:42:26 +0700 Subject: [PATCH] add close handler --- web/src/App.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/web/src/App.tsx b/web/src/App.tsx index 0f67f41..3154f91 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -20,6 +20,15 @@ function App() { const UISetting = await fetchNui('AppReady'); setSetting(UISetting); }, 2000); + const keyHandler = (e: KeyboardEvent) => { + if (e.key === 'Escape') { + fetchNui('close'); + } + }; + window.addEventListener('keydown', keyHandler); + return () => { + window.removeEventListener('keydown', keyHandler); + }; } }, [setSetting]); return (