KeyboardEvent code Property
Return the key that was pressed:
let key = event.code;Try it Yourself »
Definition and Usage
code property returns the key code when a keyboard event occurs.
code property is read-only.
code property returns different values for different
key property instead.
|Return Value:||A String, representing the key that was pressed|
event.code is a DOM Level 4 (2015) feature.
It is supported in all modern browsers:
event.code is not supported in Internet Explorer 11 (or earlier).