Is there a library that can extract all text events from an <input type=text> (or contentEditable — any one-line input field) element?
In particular, I need to know whenever the text is changed by:
- typing (asdf, backspace)
- cut/paste
- key combo actions (e.g. ctrl+bksp or option+bksp deletes the previous word)
- dragged & dropped text
- edit menu actions
And preferably what it was that changed (whether and what text was inserted, deleted, or replaced).
Needs to work on Chrome, Safari, Firefox 3+, IE9+.
The HTML5
oninputevent is supported by all those browsers and works very much like theonchangeevent, but fires as soon as the element’s input changes. It also bubbles, so you can capture it further up the document tree.Working demo: http://jsfiddle.net/Zfthe/
http://whattheheadsaid.com/2010/09/effectively-detecting-user-input-in-javascript