Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
7
rated 0 times [  11] [ 4]  / answers: 1 / hits: 21456  / 14 Years ago, sat, december 11, 2010, 12:00:00

Why isn't backspace being detected using jQuery keypress event?


$("#field").keypress(function(event){alert(event.which);});

More From » jquery

 Answers
48

The keypress event is (in its original IE form, and in Safari/Chrome) about an actual character being added to a text field. The backspace key clearly does not add a new character to the field value, so it causes no keypress event.



Firefox and Opera are a little more willy-nilly about generating typing events.



PPK (quirksmode) considers the IE and Webkit behaviors to be the sensible ones, and I pretty much agree.


[#94637] Thursday, December 9, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hasancolec

Total Points: 603
Total Questions: 95
Total Answers: 98

Location: South Korea
Member since Sat, Oct 2, 2021
3 Years ago
;