views:

1668

answers:

2

Is there any way to find out if the user pressed the delete key or dot? It has the same keycode in FireFox.

+1  A: 

According to Detecting keystrokes, it is possible, provided that:

  • you search for the keyCode (8 for delete) onkeydown/up, and
  • ignore both onkeypress and charCode (Especially if you consider the fact that IE does not fire keypressed event, only key up/down).
VonC
+6  A: 

Here is a nice overview regarding browser behavior when it comes to keyboard events:

JavaScript Madness: Keyboard Events (it's quite recent, too: July 7, 2008)

Scroll down to to "3.2. Values Returned on Character Events", there is a table showing what different browsers do.

Bottom line is: It depends.

Tomalak