0.1.4 • Published 11 years ago
typing-detector v0.1.4
Typing Detector

Detect when typing is happening.
Installation
include it on your page
<script src="dist/measurement.min.js" type="text/javascript"></script>or use browserify and npm
npm install typing-detectorTypingDetector = require('typing-detector');Basic Usage
To start initialize a new typing detector, and hook on to the events you want.
var TypingDetector = require('typing-detector');
var typingDetector = new TypingDetector({ selector: 'body' });
typingDetector
.on('typing-started', function() {
console.log('User started typing');
})
.on('typing-stopped', function() {
console.log('User stopped typing');
});
// Start detecting typing
typingDetector.start();
// or
// Call the detect function manually,
typingDetector.detect();Options
selector: (default:'body') The selector or element html element that you want to detect typing on.timeout: (default:5000) The time in milliseconds to wait before deciding that a user has stopped typing.wait: (default:0) An ammount of keystrokes to wait for before deciding if a user is typing.
Events
typing-started: Fires when a user has started typingtyping-stopped: Fires when a user has stopped typingtyping-detected: Fires each time a user's typing is detectedcount-reset: Fires when the wait count is reset
Methods
.on(eventName, cb) : Subscribe to an event.
.start() : start detecting typing on the targeted element(s).
.stop() : stop detecting typing.
.detect() : Manually detect an instance of typing, this can possibly be useful
for integrating with mv* frameworks that have their own event handling.