JSFiddle - React, Tailwind, and code Playground

by Paulpro

JavaScript

(function(){
    
    var timer;
    function resetTimer(){
        clearTimeout(timer);
        timer = setTimeout(function(){
            alert('No keydown for 10 seconds');   
            // Call reset timer here if you want the timer to start again
            // when the alert is closed

            // Otherwise, if you want to stop the timer forever,
            // remove the event handler from document.onkeydown
        }, 10000);
    }
    resetTimer();
    
    document.onkeydown = resetTimer;
    
})();