0

I tried to detect which key is pressed..

I checked it in two computers with the same browser (chrome), but I got two different results:

my func is someting like: $("input").live('keyup', function (event) {

keyPressed = event.which || event.charCode || event.keyCode || 0;

in one computer, the key down is equal to 40 but in the other computer, it equals to 82.

how can I fix it?

any help appreciated!

Maor Cohen
  • 936
  • 2
  • 18
  • 33
  • 1
    What outdated version of jQuery are you using that you can still use live? – epascarello Jun 23 '14 at 23:21
  • Well, the selected answer on that duplicate question is useless. It simply defines the problem. Also, it's not jQuery, which is fine, but it fails to point out that the jQuery event object normalizes charCode/keyCode so no need to check for them. Only event.which is needed, so you can easily use an if statement to check if String.fromCharCode(event.which) returns R. – jme11 Jun 24 '14 at 00:32

0 Answers0