Type into this field:
keydown | keyup | |
---|---|---|
.key | — | — |
.code | — | — |
modifiers | — |
When you hit or release a key, certain data is sent to the browser, and stored in the KeyboardEvent
object. This includes the .key
and the .code
values. The .key
value represents the Unicode character(s) the user expects to send to the browser when the key is pressed (ie. typically what's on the keycap). The .code
value contains a string that identifies the identity of the physical key that was pressed, rather than the intended characters to insert. The KeyboardEvent
object also has information about certain modifier keys that are depressed at the time. This app shows that information.
Note: If you hit a dead key (like an accent key) followed by another key, KeyboardEvent
sees these as separate things, and doesn't store the result of combining those. If you hit a key while using an IME (eg. for Japanese input), KeyboardEvent
doesn't capture the end result of the composition you are doing.
Learn more about KeyboardEvent
.