1

I'm executing the following code as suggested here.

$("#textBox").on("keyup", function (event) {
  foo(event.keyCode === 8 || event.keyCode === 64);
});

function foo(special) {
  console.log(special);
}

For BackSpace it works like a charm producing true. However, Del produces false. What's up with that?!

Community
  • 1
  • 1
Konrad Viltersten
  • 32,186
  • 68
  • 222
  • 392

1 Answers1

6

It's because the keycode for delete is 46 not 64.

See: http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes

gen_Eric
  • 214,658
  • 40
  • 293
  • 332
Avitus
  • 15,280
  • 6
  • 43
  • 53
  • 3
    Hrmp... Well - what the {your favorite profanity here}! I meant 64. Can't the stupid computer understand what I mean?! I was about to yell at the idiot that posted 64 in the question I linked to. But apparently someone tries to make me look dumb and changed that just now. It **was definitely** 64 before... (The bucket of shame over my head - pounding hard on it with a hammer.) – Konrad Viltersten Jul 10 '13 at 15:16