Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how do i listen to a keypress in javascript

let b = document.getElementById("body"); //making var for body
b.addEventListener("keydown", (evt) => {//when this happens
	console.log(evt.keyCode); //log keycode
});
 
PREVIOUS NEXT
Tagged: #listen #keypress #javascript
ADD COMMENT
Topic
Name
7+2 =