Search code examples
javascriptonkeypress

Javascript onkeypress delete or dot


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


Solution

  • 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).