How to check the missing events in a period of time?

How to make a popup, wait a minute if no operations no vsplyvaet popup.

How to check and count this time?

The user went to the site, which is a global event listener, if it has occurred, then the time of inactivity is reset to 0 and then increase every second + 1.
Once the time has come, give popup
March 12th 20 at 07:56
1 answer
March 12th 20 at 07:58
The decision in a forehead - listen to the mousemove event and update the timeout

document.addEventListener('DOMContentLoaded', () => {

 document.addEventListener('mousemove', () => {
clearTimeout(timeoutId);
 timeoutId = setTimeout(popupFunction, 60 * 1000)
})

 timeoutId = setTimeout(popupFunction, 60 * 1000)
});

popupFunction function() {
 alert("You've been inactive for 1 minute");
}
Not always a mouse is, if it's a phone, and the phone on different axes, especially under iOS always some sort of shit is exactly why phew....

Your answer is suitable only for desktop and only. Now 80% of Internet traffic comes from phones. - christian_Powlows commented on March 12th 20 at 08:01
Well then, touchmove and the scroll in conjunction with this

https://developer.mozilla.org/en-US/docs/Web/API/P... - Queen.Beatty62 commented on March 12th 20 at 08:04

Find more questions by tags JavaScript