e.keycode 27 code example

Example 1: difference between key and code in javascript

// Key -> if you care about the character which was typed
// Code -> if you care about the key which was pressed on the keyboard because your can change the language on your pc.
const input = document.querySelector("input");
input.addEventListener("keydown", function (e) {
  console.log(e.key);
  console.log(e.code);
});

Example 2: keycode letters

0	48
1	49
2	50
3	51
4	52
5	53
6	54
7	55
8	56
9	57
a	65
b	66
c	67
d	68	
e	69
f	70
g	71
h	72
i	73
j	74
k	75
l	76
m	77
n	78
o	79
p	80
q	81
r	82
s	83
t	84
u	85
v	86
w	87
x	88
y	89
z	90