Javascript Char Codes (Key Codes)
Jun 05, 2019
Javascript Char Codes (Key Codes),
4894 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
|
|
|