Search code examples
javascripteventskeyboardaddeventlistener

Is the KeyboardEvent always called prior to InputEvent


An HTML textarea has two event listeners attached to it:

elTextarea.addEventListener('keydown', keyDown)
elTextarea.addEventListener('input', inputEvent)

Is it certain that the keyDown() function will be called prior to inputEvent()?


Solution

  • According to the W3C

    https://w3c.github.io/uievents/#events-keyboard-event-order

    the order is keydown, beforeinput, input, keyup.