diff --git a/src/components/editor/Runner.jsx b/src/components/editor/Runner.jsx index fae8053..0439710 100644 --- a/src/components/editor/Runner.jsx +++ b/src/components/editor/Runner.jsx @@ -3,17 +3,35 @@ import {useEffect, useState} from "react"; const Runner = () => { const [hidden, setHidden] = useState(true); - useEffect(() => { - document.addEventListener("keydown", (e) => { - if (e.altKey && e.code === 'F2') { - e.preventDefault(); - alert('شما ترکیب Alt + F2 را فشردید!'); + function debounce(cb, delay) { + let timeoutId; + return function (...args) { + if (timeoutId) { + clearTimeout(timeoutId); } + + timeoutId = setTimeout(() => { + cb(...args); + }, delay); + }; + } + + const debouncedChange = debounce(() => { + setHidden(true) + }, 2000); + + useEffect(() => { + document.addEventListener("mousemove", (e) => { + e.preventDefault(); + setHidden(false) + + debouncedChange(); }) }, []) - - return(<> -
+ + return (<> +
) }