I am building a website with react and node. I have to track clicks in entire document and check if the previous click happened less then 2 minute.
2 Answers
var last = new Date().getTime();
window.addEventListener('click', function(event) {
var now = new Date().getTime();
console.log(event.pageX, event.pageY);
console.log(now-last);
console.log((now-last) / 1000);
if ( (now-last) < 2 * 60 * 1000 ) {
console.log('clicked less than two minutes ago');
}
last = now;
});