I'm trying to update the values of a text input with a close accuracy to DOM level 3 specification as possible.
keydown
keypress
beforeInput
(insertion)
input
keyup
Simply triggering the above events does not insert the character into the field, I believe this is standard across most browsers.
So I need to add the character to the e.target's value just before dispatching the input event.
The input event looks (mostly) like this:
- bubbles: true
- cancelBubble: false
- cancelable: true
- charCode: 0
- currentTarget: null
- data: "TEXT I WANT TO PASTE"
- detail: 0
- eventPhase: 0
- keyCode: 0
- returnValue: true
- target: input
- type: "textInput"
- which: 0
There's no key location value, so I'm not sure where to add the data property to the target!
Is there any data in the keydown events I need to save, and then wait for an immediately following input event? Can I add the data to the input solely based on the information given by input event?
valueof an input, so I'm doing it manually. Not sure why browsers work this way, however. If someone could explain it in an answer I'd accept :-)