I am showing and hiding some modals by altering their CSS properties. I want them to be displayed until there is no key event in last 3 seconds. Is there a way to handle this via JavaScript? VueJs solutions would be better.
I am currently hiding the modal after 3 seconds like this :
function a(){
document.querySelector("#playPause").style.display = "block";
setTimeout(() => {
document.querySelector("#playPause").style.display = "none";
}, 3000);
}
#playPause{
display:none;
background-color:black;
}
<button onclick="a()">Display</button>
<div id="playPause">EXAMPLE</div>