difference between key and code in javascript

Solutions on MaxInterview for difference between key and code in javascript by the best coders in the world

showing results for - "difference between key and code in javascript"
Jana
04 Aug 2017
1// Key -> if you care about the character which was typed
2// Code -> if you care about the key which was pressed on the keyboard because your can change the language on your pc.
3const input = document.querySelector("input");
4input.addEventListener("keydown", function (e) {
5  console.log(e.key);
6  console.log(e.code);
7});