event.code property
The event.code property allows you
to find out the code of a pressed key
when entering text.
Syntax
event.code;
Example
Let's output the code of a pressed key to the console:
<input id="elem">
let elem = document.querySelector('#elem');
elem.addEventListener('keydown', function(event) {
console.log(event.code);
});
See also
-
the
event.keyproperty
that obtains an entered character