detect if idle inactivity - Free Download Detect If The User Is Idle In jQuery - Inactivity

Free Download Detect If The User Is Idle In jQuery – Inactivity

Posted on

This time I will share jQuery Plugin and tutorial about Detect If The User Is Idle In jQuery – Inactivity, hope it will help you in programming stack.

detect if idle inactivity - Free Download Detect If The User Is Idle In jQuery - Inactivity
File Size: 6.42 KB
Views Total: 422
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

A tiny and mobile-friendly jQuery idle detection plugin that detects user’s activities (keyboard, mouse, touch, or custom events) and fires an ‘Inactivity’ event when the user has been idle for a certain amount of time.

Default Events To Track:

  • mouseEvents: mousemove, mousedown, mousewheel, wheel, DOMMouseScroll, MSPointerDown, MSPointerMove
  • keyboardEvents: keypress, keydown, keyup
  • touchEvents: touchstart, touchmove, touchend

How to use it:

1. Place the minified version of the Inactivity plugin after loading the latest jQuery.

1 <script src="/path/to/cdn/jquery.slim.min.js"></script>
2 <script src="/path/to/src/jquery.inactivity.min.js"></script>

2. Initialize the plugin on the whole document.

1 $(document).inactivity( {
2   // options here
3 });

3. Fire an event when a user is idle.

1 $(document).on("inactivity", function(){
2   // do something when a user is idle
3 });

4. Fire an event when a user is active.

1 $(document).on("activity", function(){
2   // do something when a user is active
3 });

5. Determine whether to detect mouse events. Default: true.

1 $(document).inactivity( {
2   mouse: false
3 });

6. Determine whether to detect keyboard events. Default: false.

1 $(document).inactivity( {
2   keyboard: true
3 });

7. Determine whether to detect keyboard events. Default: false.

1 $(document).inactivity( {
2   touch: true
3 });

8. Determine whether to use custom events. Default: ”.

1 $(document).inactivity( {
2   customEvents: "customEventName"
3 });

9. Determine whether to trigger only the first “activity” event. Default: false.

1 $(document).inactivity( {
2   triggerAll: false
3 });

This awesome jQuery plugin is developed by readyforaliens. For more Advanced Usages, please check the demo page or visit the official website.