Reputation: 239107
As far as I understand, the "onchange" event of a text input element is only fired when two conditions are true:
So when you click off, it fires the event. How can I fire an event when the text has changed, but the field still has focus?
Upvotes: 0
Views: 475
Reputation: 536735
Reliably? You can't, yet.
You can catch the majority of changes by firing your update checker onkeyup
as well as onchange
. However whilst this picks up simple keyboard interactions, it fails to trigger on other events like cut-and-paste (there is onpaste
in some browsers, but you can't rely on it), drag-and-drop, undo-redo and spellchecker changes.
HTML5 proposes oninput
to solve this, but the implementation isn't there yet. If you really want to spot all input changes today you will have to setInterval
a function that keeps checking the input's value to see if it has changed.
Upvotes: 2
Reputation: 10081
you have access to the keypress
, keyup
, and keydown
events; the details of when those fire can be found at Quirksmode.
Upvotes: 2