0

I asked a similar question but it seems maybe I did not get what I really need.

The last question: here

My goal:

I am writing a record and replay Chrome extension, I have recorded user`s keyboard press and now I need to replay it.

I have a list of keyCodes:

[42, 43, 0, 11...]

I need to simulate a keyboard press for each one on the document.activeelement * If regular char - add it to the input \ textarea value, if backspace delete prev char, if delete - delete next char, if arrows - move the selector right \ left and etc.. (I expect normal behavior as I would press the same key)

As I mentioned in the last question - I tried many options and I added code samples. but it seems I am not understanding yet what I am really need to do for that result.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Oz Bar-Shalom
  • 1,747
  • 1
  • 18
  • 33
  • Why not use jquery? –  Oct 16 '16 at 11:34
  • It is a third party extension. I don`t want to load jquery on different version to the website. I wrote the whole extention with pure JS so far and I want to finish it that way.. – Oz Bar-Shalom Oct 16 '16 at 11:38
  • IIRC even if you generate these events Chrome knows they're not a real user input so doesn't modify text etc (although handlers do fire). You will need to look at the caret/selection and do string manipulation as well as fire the event – Paul S. Oct 16 '16 at 11:38
  • Is that mean I will have to map all the options? and write a switch case for that? sounds teribble – Oz Bar-Shalom Oct 16 '16 at 11:39
  • look at what jquery does. this question is duplicate of your other one. – Zig Mandel Oct 16 '16 at 13:01

0 Answers0