Firebug: “The 'charCode' property of a keyup event should not be used. The value is meaningless.”

前端 未结 3 1296
故里飘歌
故里飘歌 2021-01-21 10:06

I\'m building a calculator, and am using the following:

jQuery(function($) {
    $(\'#Quantity\').keyup(function() {
        console.log($(this).val());
    });
         


        
3条回答
  •  日久生厌
    2021-01-21 10:57

    This is not directly answering your question, but might provide useful information.

    From quirksmode.org:

    keyCode and charCode

    The two properties are keyCode and charCode. Put (too) simply, keyCode says something about the actual keyboard key the user pressed, while charCode gives the ASCII value of the resulting character. These bits of information need not be the same; for instance, a lower case 'a' and an upper case 'A' have the same keyCode, because the user presses the same key, but a different charCode because the resulting character is different.

    Explorer and Opera do not support charCode. However, they give the character information in keyCode, but only onkeypress. Onkeydown and -up keyCode contains key information.

    I can only assume that the charCode value is "meaningless" if a key is pressed that does not print a character (like arrow keys). Also, the charCode might be different from what you expect if the user uses a non-English keyboard. But I am not sure about this.

提交回复
热议问题