Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a generic window.onevent in javascript?

I am trying to make a JavaScript (jQuery is fine as well) function to check how long a user has been inactive for on the current page. I know that in JavaScript there are specific window events like window.onload, window.onmousemove, etc. But I was wondering if there was any function that captures any event (such as a mouse move, key press, or anything else that indicates activity by the user on the page) without having to set all of those event listeners manually?

like image 479
Zak Avatar asked Dec 28 '22 03:12

Zak


1 Answers

There's no inactive event that I'm aware of.

I'm assuming JQ is fair game since you tagged it. You can bind multiple events with one bind statement so something like this should work:

$('body').bind('mousedown keydown mousemove', resetInactiveTimer);
like image 195
Erik Reppen Avatar answered Jan 09 '23 18:01

Erik Reppen