Know when your users are using your site.
- Detects inactive keyboard.
- Detects inactive mouse movement.
- Detects no window visibility.
- Detects lost window focus.
- Easily enable/disable features that only need to be active when a user is using your site.
Download the script and include it on your site:
<script src="activity.min.js"></script>
Or install it with bower:
$ bower install activity --save
At the end of your code, right before </body>
, call the following:
Activity.detect();
Once this is done, you'll be able to detect user activity by listening to either the user_active
or user_inactive
events, as shown below:
Activity.on('active', function () {
console.log("The user is active!");
});
Activity.on('inactive', function () {
console.log("The user is inactive!");
});
If you want to build /src
files to /dist
, then simply run:
$ npm install
$ npm run build
MIT, see LICENSE.