node package manager


detect when a user is idle on a page


detect idle users on webpages

var away = require('away');
// detect users who are idle for 10 seconds 
var timer = away(10000);
timer.on('idle', function() {
    console.log('user is idle');
timer.on('active', function() {
    console.log('user is active');

away() returns a Timer object which exposes the following methods.

Call fn when user becomes idle.

Call fn when user becomes active after having been idle.

Stop the idle timer from detecting user activity

Start the idle timer. (By default the idle timer is started automatically)

idle() accepts a second argument with additional options.

The dom element to monitor for activity. (default document)

Milliseconds before user is considered idle. (default 30000)

String of DOM events that will trigger activity. (see index.js for default)

Whether to start idle timer upon creation. (default true)

npm isnstall away

Inspired by the jquery-idletimer plugin.