Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Record/playback keystrokes in textfield using Javascript

Is it possible to record a user's input into an HTML textfield, and playback at a later date in realtime? One way I can think of would be to capture each keyDown event and the time delta (accurate to a few hundred ms), and store the pairs together.

Can you think of a better/more efficient way?

like image 265
James Avatar asked May 13 '10 22:05

James


1 Answers

The handler which is returned by KeyDown handler contains all the informations you need to do what you want.

Try this in firebug:

$('#your-input').keydown(
    function(e) { 
        console.log(e.timeStamp);
        console.log(e.keyCode);
    }
);

You just have to store the data from the handler (var e) which has timeStamp property and keyCode.

You can then set a timer with the difference between to keydown to simulate them.

like image 196
Boris Guéry Avatar answered Sep 23 '22 00:09

Boris Guéry