From c4e1626d35a0b1d65fafd78240639dc37b483955 Mon Sep 17 00:00:00 2001 From: Vivek Arya Date: Tue, 26 May 2026 20:02:59 +0530 Subject: [PATCH] feat: Add Quick Exit (Panic Button) for immediate safety redirection --- src/App.tsx | 2 ++ src/components/QuickExit.tsx | 52 ++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 src/components/QuickExit.tsx diff --git a/src/App.tsx b/src/App.tsx index e9c0b9e..65221a0 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -14,6 +14,7 @@ import AdminDashboard from './pages/AdminDashboard'; import FAQs from './pages/FAQs'; import ScrollToTop from './components/ScrollToTop'; import BackToTop from './components/BackToTop'; +import QuickExit from './components/QuickExit'; import PrivacyPolicy from './pages/Privacypolicy'; import Termsandconditions from './pages/termsandconditions'; import ContactPage from './pages/ContactPage'; @@ -28,6 +29,7 @@ function App() { {/* // Global back-to-top button available across all pages */} +
diff --git a/src/components/QuickExit.tsx b/src/components/QuickExit.tsx new file mode 100644 index 0000000..cf7313f --- /dev/null +++ b/src/components/QuickExit.tsx @@ -0,0 +1,52 @@ +import { useEffect, useRef } from "react"; +import { AlertTriangle } from "lucide-react"; + +export default function QuickExit() { + // Weather.com or Google are commonly used benign exit sites + const exitSite = "https://www.google.com"; + const clicksRef = useRef([]); + + const handleExit = () => { + // replace() prevents the SafeVoice website from appearing in the back button history + window.location.replace(exitSite); + }; + + useEffect(() => { + const handleKeyDown = (e: KeyboardEvent) => { + if (e.key === "Escape") { + const now = Date.now(); + clicksRef.current.push(now); + + // Keep only clicks within the last 2 seconds (2000ms) + clicksRef.current = clicksRef.current.filter((time) => now - time <= 2000); + + // Trigger exit on 3 quick presses + if (clicksRef.current.length >= 3) { + handleExit(); + } + } + }; + + window.addEventListener("keydown", handleKeyDown); + return () => window.removeEventListener("keydown", handleKeyDown); + }, []); + + return ( +
+ +
+ ); +}