Mathias Bynens 5/11/2011

Using the `oninput` event handler with `onkeyup`/`onkeydown` as its fallback

Read Original

This technical article discusses the standardized HTML5 `oninput` event for detecting user input in JavaScript. It explains why `oninput` is preferable to `onkeyup`/`onkeydown`, covers browser support (including IE9), and details a practical fallback technique. The method involves binding both `oninput` and `onkeydown` events, then removing the keydown handler once `oninput` fires, avoiding complex feature detection. Code examples are provided in plain JavaScript and as a jQuery plugin.

Using the `oninput` event handler with `onkeyup`/`onkeydown` as its fallback

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser

Top of the Week

No top articles yet