0

Is the order of keydown and keypress always atomic? When being in the keypress handler, is it guaranteed that the last keydown event belongs to the keypress event?

Razer
  • 7,843
  • 16
  • 55
  • 103

1 Answers1

1

JavaScript is by nature single threaded. Thus, when one event is dispatched, it is put on the queue until all previous events are processed. Therefore, as long as the browser receives the events in the right order (Dependant on having a sane OS etc), the events you receive are dispatched in the order they happened.

On a related note: https://stackoverflow.com/a/7266985/1702990

Community
  • 1
  • 1
Sinkingpoint
  • 7,449
  • 2
  • 29
  • 45