How to programmatically enter text with JavaScript events

I am trying as best as possible to update text input values ​​accurate to DOM level 3.

keydown keypress beforeInput (Insert) input keyup

Just triggering these events does not insert a character into the field, I believe that this is standard for most browsers.

Therefore, I need to add a character to the value e.targetimmediately before sending the event input.

The input event looks (basically) like this:

  • bubbles: true
  • cancelBubble: false
  • cancelable: true
  • charCode: 0
  • currentTarget: null
  • data: "TEXT I WANT TO PAST"
  • detail: 0
  • eventPhase: 0
  • keyCode: 0
  • returnValue: true
  • target: input
  • type: "textInput"
  • which: 0

There is no key location value, so I'm not sure where to add the property datato the target!

- keydown, , ? , ?

+4
1

, ?

, spec, InputEvent, .targetRanges.

2016 , .

, § 3.10. DOM :

, . -, (, preventDefault()). , . , .

, DOM " ", , . , , .

, API-, , ...

- .

+2

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


All Articles