Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
-3
rated 0 times [  1] [ 4]  / answers: 1 / hits: 18418  / 12 Years ago, tue, april 17, 2012, 12:00:00

I'm finding that the delete key doesn't fire the keypress event in Chrome, while other keys work. The problem doesn't occur in Firefox, just in Chrome, why? Here is my code:


document.addEventListener('keypress', function (e) {
console.log(e);
}, false);

More From » dom-events

 Answers
48

Use keydown or keyup instead, it captures the delete key (as well as others that keypress doesn't, see http://www.quirksmode.org/js/keys.html)



document.addEventListener('keydown', function (e) {
console.log(e);
}, false);

[#86194] Monday, April 16, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
deniseryannd

Total Points: 169
Total Questions: 85
Total Answers: 96

Location: Virgin Islands (U.S.)
Member since Fri, May 7, 2021
3 Years ago
;