record and playback user keystrokes. use this tool ethically -- never collect user data without their explicit knowledge + consent.
npm i --save keystroke-recorder
import $ from 'jquery'
import KeystrokeRecorder from 'keystroke-recorder'
var keystrokeRecorder = new KeystrokeRecorder({
omittedKeys: ['Tab', 'Meta', 'Control', 'Alt', 'Shift']
})
$('#record-btn').click(() => {
keystrokeRecorder.record()
})
$('#stop-btn').click(() => {
keystrokeRecorder.stop()
console.log(keystrokeRecorder.json)
})
$('#replay-btn').click(() => {
keystrokeRecorder.replay('#replay-pad').then(() => {
console.log('done replaying!')
})
})
-
an array of keys to be ignored during recording. default: []
-
starts collecting keystroke data as json
-
stops collecting keystroke data
-
replays recorded keystrokes in DOM element with specified selector. returns a promise that resolves on completion.
-
stops recording and loads given json into keystrokeRecorder
-
return milliseconds since recording started
-
returns json data for last keystroke recording
[ { keyCode: 65, key: "a", ms: 562 }, { keyCode: 83, key: "s", ms: 771 }, { keyCode: 68, key: "d", ms: 998 }, { keyCode: 70, key: "f", ms: 1642 } ]
-
time that last recording started at
-
boolean indicating whether
keystrokeRecorder
is recording or not