onKeyPress event not working in Firefox

后端 未结 4 1813
闹比i
闹比i 2020-12-01 18:58

I have the following javascript code...Here I am using onKeyPress=\"someFunction( )\" in the body tag to get the keyCode of the key that is pressed.

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-01 19:43

    I think Firefox are not caring programmers... and this is the reason why so, In Firefox navigator.appName returns "Netscape". so user can edit his code like,

    if(navigator.appName == "Netscape") 
        Key = event.charCode; //or e.which; (standard method)
    else 
        Key = event.keyCode;
    

提交回复
热议问题