KeyboardEvent code Property
Definition and Usage
The code property returns the key that triggered the event.
Note: This property returns different values for different keyboard layouts.
Tip: To make sure you return the correct character, use
event.key
instead
Browser Support
Property | |||||
---|---|---|---|---|---|
code | 48 | Not supported | 32 | 10 | Yes |
Syntax
event.code
Technical Details
Return Value: | A String, representing the key that was pressed |
---|
Related Pages
HTML DOM reference: KeyboardEvent key Property
HTML DOM reference: KeyboardEvent charCode Property
HTML DOM reference: KeyboardEvent keyCode Property