feat(settings modal): close with escape key

This commit is contained in:
Tom (plebeius.eth)
2025-01-30 22:05:54 +01:00
parent 63cb5b6591
commit 01e467d069
@@ -21,6 +21,19 @@ const SettingsModal = () => {
navigate(newPath);
};
useEffect(() => {
const handleEscape = (e: KeyboardEvent) => {
if (e.key === 'Escape') {
closeModal();
}
};
document.addEventListener('keydown', handleEscape);
return () => {
document.removeEventListener('keydown', handleEscape);
};
}, [closeModal]);
const [showInterfaceSettings, setShowInterfaceSettings] = useState(false);
const [showAccountSettings, setShowAccountSettings] = useState(false);
const [showAvatarSettings, setShowAvatarSettings] = useState(false);