📜  HTML | KeyboardEvent which 属性

📅  最后修改于: 2021-10-29 04:40:55             🧑  作者: Mango

KeyboardEvent 属性用于返回触发onkeypress事件的键的 Unicode字符代码。它还返回触发onkeydownonkeyup事件的键的 Unicode 键码。
键码是一个数字,代表键盘上的实际键,与代表 ASCII字符的字符码不同。

句法 :

event.which

下面的程序说明了 KeyboardEvent 哪个属性:
示例:返回密钥的 Unicode字符代码。



  

    KeyboardEvent which Property in HTML
    

  

  
    

GeeksforGeeks

    

KeyboardEvent which Property

       

To get the Unicode character code of the key,        Press the key on the keyboard in the input field.

               

               

输出:

点击按钮后

支持的浏览器:

  • 歌剧
  • IE浏览器
  • 谷歌浏览器
  • 火狐
  • 苹果Safari