Skip to content

Guja1501/sensor-afk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SensorAFK

Donate npm version

Sensor away from keyboard (element)

Sensor AFK was created for Laravel package: rangoo/lockscreen

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Installing

This package can be installed with:

  • npm: npm install --save sensor-afk

Examples

const SensorAFK = require('sensor-afk');

let wasAfk = false;

let sensor = new SensorAFK({
	time: 30,
	sensors: 'click wheel mousemove keydown keyup keypress',
	node: document,
	callback: () => {
		if(wasAfk) {
			alert('You are afk again :/');
		} else {
			alert('You are afk!');
		}
		
		wasAfk = true;
	}
});

// trigger events manually
sensor.flush();
sensor.stop(); // doesn't shut downs sensor. Just waiting next flush
sensor.start();
sensor.afk(); // callback is triggered here

sensor.off(); // turns off sensor
sensor.on(); // turns on sensor
sensor.toggle(); // toggle on/off sensor

Default Options:

{
	time: 30,
	sensors: 'click wheel mousemove keydown keyup keypress',
	node: document,
	callback: () => {
		// default callback does nothing
	}
}

Deployment

Add additional notes about how to deploy this on a live system

Built With

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

  • Guja Babunashvili - Initial work - Guja1501

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE file for details