how do i make the onkeypress with a keycode in javascript code example

Example 1: js when key is pressed

document.addEventListener("keypress", function(event) {
	// do stuff
});

Example 2: 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);
});