.keypress vs .keydown Description on the jQuery API Documentation
I built a textarea length monitor a while back, and when I was doing it, I used the API documentation which said, and still says, that .keydown only fires once if a key is pressed and held down. If I want my monitor to update as the key is held down (every time a character is added), I'd need to use .keypress.
I was testing this in IE10 today and found that .keypress only works for inserting characters on IE. Pressing backspace or delete doesn't fire the event. (Those keys do fire it in FF/Chrome). I switched over to .keydown to test, and lo and behold, pressing and holding a key sends continuous firing.
My question is, is the continuous firing only on modern browsers? (I only tested in IE9-10, and current FF/Chrome). Either way, we need to update the API documentation which currently reads:
In my monitor I just duplicated the binding and used both keypress and keydown to be safe, because updating the monitor if nothing is changed doesn't do any harm.
event is sent to an element when the browser registers keyboard input. This is similar to the
event, except in the case of key repeats. If the user presses and holds a key, a
event is triggered once, but separate
events are triggered for each inserted character. -