9

I am working with jQuery in this when I try e.keyCode For enter key like below

    if (e.keyCode === 13) {
// my code
    }

then it works with ie7 and all major browsers but not in ie10.

But when I use e.which it runs in all major browsers.

What is the difference between e.keyCode and e.which?

Sergey L.
  • 21,822
  • 5
  • 49
  • 75
Rituraj ratan
  • 10,260
  • 8
  • 34
  • 55

1 Answers1

18

The event.which property normalizes event.keyCode and event.charCode. It is recommended to watch event.which for keyboard key input.

As per JQuery documentation

keyCode is standard JavaScript and of course not implemented in the same way by all browsers.

mucio
  • 7,014
  • 1
  • 21
  • 33