Skip to content

Input's onChange Event Handler Misses Key Strokes? #668

Answered by rmorshea
jkrobicki asked this question in Question
Discussion options

You must be logged in to vote

Ok, looking into this, there may not be a great way to resolve the underlying issue. What's happening is that, because there's a delay between a key being typed and the character showing up in the input, it's possible to press another key before the first one has been rendered to the screen. Let's say we want to type "world" and we do so at a rate which is double that of the render rate (that is we type two keys in the time we render once). When we look at the event.target.value for each onChange event we'd see the following:

  1. "w"
  2. "o"
  3. "or"
  4. "ol"
  5. "old"

This happens because by the time we type "o", the "w" hasn't appear in the input yet. Thus the change from "" to the most recently typed "o"

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@rmorshea
Comment options

Comment options

You must be logged in to vote
1 reply
@rmorshea
Comment options

Answer selected by rmorshea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants