This is resolved by the browser. You can also trigger for values changed on text inputs by attaching a handler to the onchange event:
<input onchange="alert('value changed!');" />
And also in Javascript:
document.getElementById("my_text_input").onchange = function(){
alert("value changed!");
}
Of course you can replicate this behaviour. You can try it yourself here.
[Edit]
You have the onblur event, which fires every time the user leaves the control.
You could keep track of the input value, or set a flag to be accesible for both change and blur events:
(function(){
var changed = false;
document.getElementById("my_text_input").onchange = function(){
changed = true;
}
document.getElementById("my_text_input").onblur = function(){
if (!changed) {
//Your logic here
}
changed = false; //set it back to false for next loss of focus
}
})();