add close handler

This commit is contained in:
Lorraxs 2024-03-23 10:42:26 +07:00
parent 258cef324f
commit fac673c048

View File

@ -20,6 +20,15 @@ function App() {
const UISetting = await fetchNui<UISetting>('AppReady'); const UISetting = await fetchNui<UISetting>('AppReady');
setSetting(UISetting); setSetting(UISetting);
}, 2000); }, 2000);
const keyHandler = (e: KeyboardEvent) => {
if (e.key === 'Escape') {
fetchNui('close');
}
};
window.addEventListener('keydown', keyHandler);
return () => {
window.removeEventListener('keydown', keyHandler);
};
} }
}, [setSetting]); }, [setSetting]);
return ( return (