2

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);
        });
Justin808
  • 20,859
  • 46
  • 160
  • 265
  • I am unable to duplicate this behavior on [the demo page for event.which](http://api.jquery.com/event.which/) using IE8 8.0.7600.16385 on Windows 7 64-bit. Maybe it's a problem with keyCode? – Charles Jul 22 '10 at 03:04

2 Answers2

3

use which:

  $('.AddressField').keypress(function(e){
       alert(e.which);
   });
Garis M Suero
  • 7,974
  • 7
  • 45
  • 68
  • Why does IE make things so difficult :-( Thanks, this worked great. I'm checking keyCode and which at this point just to be sure. – Justin808 Jul 22 '10 at 17:54
0

keyCode property is not available in IE. In IE you must use which property.

Strelok
  • 50,229
  • 9
  • 102
  • 115