Answer to "javascript listener, “keypress” doesn't detect backspace?" (http://stackoverflow.com/questions/4843472/javascript-listener-keypress-doesnt-detect-backspace/)
Single keyclick
--------------------
On Chrome:
- keydown/keypress/keyup when browser registers a keyboard input (keypress is fired)
- keydown/keyup if no keyboard input (tested with alt, shift, backspace, arrow keys)
- keydown only for tab?
On Firefox
- keydown/keypress/keyup when browser registers a keyboard input (keypress is fired) and also for backspace, arrow keys, tab
- keydown/keyup for alt, shift
The JQuery which returns the charcode when this is not 0, otherwise it returns the keycode.
Note that for digits 0,1,..,9 keycode=charcode but this is not true for non-numeric characters.
Quote from https://api.jquery.com/keypress/
"Note: as the keypress event isn't covered by any official specification, the actual behavior encountered when using it may differ across browsers, browser versions, and platforms."
Press key in the input box to see what events and codes are detected by your browser (<i>from Stackoverflow <a href="http://stackoverflow.com/questions/4843472/">javascript-listener-keypress-doesnt-detect-backspace</a></i>)
<p>
<input class="inputTxt" type="text" />
<div id="log"></div>
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.