Answers for "difference between key and code in javascript"

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);
});
Posted by: Guest on November-12-2020

Code answers related to "difference between key and code in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language