0
Q:

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);
}); 
1

New to Communities?

Join the community