Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

handle esc press js

//Check if the key is the Escape key, also known as 27 in the ASCII table
const pressEsc = (event) => {
	if(event.key === "Escape"){
    	console.log("You pressed Esc button")
    }
}

//Listen to the global keydown, the callback function will give us the wanted result
window.addEventListener("keydown", pressEsc)
 
PREVIOUS NEXT
Tagged: #handle #esc #press #js
ADD COMMENT
Topic
Name
3+7 =