$(window).keypress(function()) does not work in IE7?
19,748
Solution 1
IE doesn't support key events on the window
.
Place it on the document
instead.
$(document).keypress(function(e) {
alert('hello world');
});
Solution 2
Currently I have no IE7 to test it, but I believe you have to assign the event handler to $(document) instead of $(window). Something like:
$(document).keypress(function(e) {
alert("hello world");
});
Author by
AP257
Updated on June 16, 2022Comments
-
AP257 almost 2 years
This keypress event works fine for me in Chrome and Firefox, but simply isn't being picked up at all in IE7:
$(window).keypress(function(e) { alert('hello world'); });
Does anyone know alternatives for IE7?
Or is it an error higher up in my JavaScript that means it isn't being picked up in IE7 - in which case, how can I debug it? I have script errors turned on in IE, but nothing is popping up.