Record / play keystrokes in a text field using Javascript

Is it possible to record user input in an HTML text box and play it later in real time? One way I can imagine is to capture each keyDown event and a time delta (accurate to several hundred ms) and store the pairs together.

Can you think of a more efficient and effective way?

+4
source share
1 answer

The handler returned by the KeyDown handler contains all the information you need to accomplish what you want.

Try this in firebug:

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

You just need to save the data from the handler (var e), which has the timeStamp and keyCode property.

Then you can set a timer with the difference between the keys to simulate them.

+4
source

Source: https://habr.com/ru/post/1309712/


All Articles