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?
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With