问题
I've got a simple javascript keydown event coded via jquery. The event should just alert the key that is "down." This works for most keys but not the backspace key in Internet Explorer. I read that IE messes this up on the keypress event but was supposed to work for the keydown and keyup events.
Is there anything I can do via jquery to capture the backspace in IE? The version of IE I'm currently testing in is:
8.0.7600.16385
$('.AddressField').bind("keydown", function (e) {
alert(e.keyCode);
});
回答1:
use which:
$('.AddressField').keypress(function(e){
alert(e.which);
});
回答2:
keyCode
property is not available in IE. In IE you must use which
property.
来源:https://stackoverflow.com/questions/3305480/how-do-i-capture-the-backspace-key-in-ie8-with-jquery