sensor-afk
v1.1.3
Published
SensorAFK triggers event when client goes away from keyboard
Downloads
13
Readme
SensorAFK
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
- Laravel Mix - Laravel Mix for compiling files
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