HTML DOM KeyboardEvent
KeyboardEvent Object
An event occurs when a user presses a key on the keyboard, which belongs to the KeyboardEvent object.
Attribute/Method | Beskrivning |
---|---|
altKey | Return whether the "ALT" key was pressed when the key event was triggered. |
charCode | Return the Unicode character code of the key that triggered the onkeypress event. |
code | Return the code of the key that triggered the event. |
ctrlKey | Return whether the "CTRL" key was pressed when the key mouse event occurred. |
getModifierState() | Return true if the specified key is activated. |
isComposing | Return whether the state is being composed by the event. |
key | Return the key value represented by the event. |
keyCode | Return the Unicode character code of the key that triggered the onkeypress event, or the Unicode key code of the key that triggered the onkeydown or onkeyup event. |
location | Return the position of the key on the keyboard or device. |
metaKey | Return whether the "META" key was pressed when the key event was triggered. |
repeat | Return whether a key is being held down repeatedly. |
shiftKey | Return whether the "SHIFT" key was pressed when the key event was triggered. |
which | Return the Unicode character code of the key that triggered the onkeypress event, or the Unicode key code of the key that triggered the onkeydown or onkeyup event. |
Inheriterade egenskaper och metoder
KeyboardEvent ärver alla egenskaper och metoder från följande objekt:
Händelsetyp
Dessa händelsetyper tillhör KeyboardEvent-objektet:
Händelse | Beskrivning |
---|---|
onkeydown | Detta händelse inträffar när användaren håller ner en tangent. |
onkeypress | Detta händelse inträffar när användaren trycker på en tangent. |
onkeyup | Detta händelse inträffar när användaren släpper en tangent. |