I have a requirement where i need to capture all the keys that a user has pressed and replay the same in the browser after a delay. E.g> if i have 3 text fields in a form, only field-1 will be enabled and focused on page load. Field-1 has a fousout event which will enable field-2, and field-3 after 10 seconds. Now user does the following without looking at the screen.
- User keys in "XYZ" in field-1.
- then immediately presses "TAB" key.
- keys in "123"
- presses "TAB" key
- keys in "XYZ123"
- presses "ENTER" key
all this is done in less than 10 seconds. i have done evt.preventDefault() for TAB and ENTER so that it does not submit the form nor tab away from the document. - How do i simulate the above keystrokes after 10 seconds?
I would want the results in the same order the user keyed in. i.e. - add values "123" to field-2 - most importantly invoke the browser TAB key functionality! - add then add values "XYZ123" to field-3 and so..on.
- Is this achievable using javascript? e.g. Store all the keypress events and fire them one by one after 10 seconds?