Bàn phím HTML DOMSự kiện
❮ Sự kiện DOM ❮ Đối tượng sự kiện
Đối tượng sự kiện bàn phím
Đối tượng KeyboardEvent xử lý các sự kiện xảy ra khi người dùng nhấn một phím trên bàn phím.
Sự kiện bàn phím
Event | Occurs When |
---|---|
onkeydown | A user presses a key |
onkeypress | A user presses a key |
onkeyup | A user releases a key |
Thuộc tính sự kiện bàn phím
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) |
Bàn phímPhương thức sự kiện
Method | Description |
---|---|
getModifierState() | Returns true if the specified key is activated |
Thuộc tính và phương thức kế thừa
KeyboardEvent kế thừa tất cả các thuộc tính và phương thức từ: