Before HTML5, we had to use the onkeypress event (or similar) to detect when a user adjusts the text in an input field. This often created synchronization problems and didn’t work at all with on-screen keyboards, thus requiring us to bind multiple events. HTML5 solves this problem by defining the oninput event. Since HTML5 is not yet universally supported, however, it is often safer to use the oninput event along with the onkeypress event for backwards compatibility.
While writing a validation script, I recently discovered that the following works in jQuery:
$('input').bind('input', function() {...});
However, there seems to be very little documentation (if any) on this. My question is this: since this is implemented in jQuery (which should already be backwards compatible), is it necessary to include ‘backup’ events such as onkeypress?
I suppose there’s nothing wrong with throwing a few extra bindings in:
$('input').bind('input keydown mousedown', function() {...});
but it would be nice to know whether or not the extra bindings are necessary.
I think you should think about backward compatibility because it’s not supported in all browsers and for more information you can see here.