matt matt - 1 year ago 109
jQuery Question

jQuery: keyPress Backspace won't fire?

I wonder what I'm doing wrong:

$('.s').keypress(function(e) {

switch (e.keyCode) {
case 8: // Backspace
case 9: // Tab
case 13: // Enter
case 37: // Left
case 38: // Up
case 39: // Right
case 40: // Down




I want my
function also to be fired when I hit the Backspace key. At the moment absolutely nothing happens when I press Backspace in Chrome and Safari.

any ideas?

Answer Source

Use keyup instead of keypress. This gets all the key codes when the user presses something