KeyboardEvent 对象处理用户按下键盘上的按键时发生的事件。
Event | Occurs When |
---|---|
onkeydown | A user presses a key |
onkeypress | A user presses a key |
onkeyup | A user releases a key |
Property | Returns |
---|---|
altKey | If the ALT key was pressed |
charCode | Deprecated (Avoid using it) |
code | The code of the key that triggered the event |
ctrlKey | If the CTRL key was pressed |
isComposing | If the state of the event is composing or not |
key | The value of the key that triggered the event |
keyCode | Deprecated (Avoid using it) |
location | The location of a key on the keyboard or device |
metaKey | If the META key was pressed |
repeat | If a key is being hold down repeatedly, or not |
shiftKey | If the SHIFT key was pressed |
which | Deprecated (Avoid using it) |
Method | Description |
---|---|
getModifierState() | Returns true if the specified key is activated |
KeyboardEvent 继承了以下所有属性和方法:
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!