KeyboardEvent code Property
Description
The code property returns the key code when a keyboard event occurs.
The code property is read-only.
Warning!
The code property returns different values for different
keyboard layouts.
Use the key property instead.
See Also:
Syntax
event.code
Technical Details
| Return Value: | A String, representing the key that was pressed |
|---|
Browser Support
event.code is a DOM Level 4 (2015) feature.
It is supported in all modern browsers:
| Chrome | Edge | Firefox | Safari | Opera |
| Yes | Yes | Yes | Yes | Yes |