Javascript Char Codes (Key Codes)
Jun 24, 2021
Javascript Char Codes (Key Codes),
3303 Views
Javascript Char Codes (Key Codes)
Javascript Char Codes (Key Codes)
In most the browser there are three possible kinds of events triggered when a keyboard key is pressed or released:
- keydown
- keypress
- keyup
Whenever a KeyboardEvent triggered, you can check which key was pressed or released because that event contains information which you can write logic against.
document.addEventListener("keydown", function(event) {
console.log(event.which);
console.log(event.keyCode);
console.log(event.shiftKey);
console.log(event.altKey);
console.log(event.ctrlKey);
console.log(event.metaKey);
}
# Table of KeyCodes
|
|
|