Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

keypress javascript

window.addEventListener("keydown", function(event) {
	if (event.key == 'key') {
		// do thing
	}
});
Comment

keypress javascript

The keypress event has been deprecated, 
you should look to use beforeinput : https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/beforeinput_event
or keydown : https://developer.mozilla.org/en-US/docs/Web/API/Document/keydown_event
instead.

(And don't forget to like answers that help you !)
Comment

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
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: run build version react 
Javascript :: jquery remove focus 
Javascript :: select document jquery 
Javascript :: ng class in angular 
Javascript :: install react native gifted charts 
Javascript :: toast in react native 
Javascript :: jquery select all except first child 
Javascript :: queryselector data attribute 
Javascript :: sequelize order by 
Javascript :: javascript get last url segment 
Javascript :: how to check if div is display none jquery 
Javascript :: Handle an input with React hooks 
Javascript :: javascript check if number is hexadecimal 
Javascript :: vuejs input text 
Javascript :: google sheet app script 
Javascript :: get datetime yesterday angular 
Javascript :: remove matching element from two array javascript 
Javascript :: include jsp in another jsp 
Javascript :: javascript round down 
Javascript :: extract urls from string javascript 
Javascript :: reset redux form after validation 
Javascript :: javascript check if required 
Javascript :: generate thumbnail of pdf using pf js 
Javascript :: node fs exists 
Javascript :: cryptojs decrypt 
Javascript :: javascript date time formating 
Javascript :: how to change checkbox state in jquery 
Javascript :: read a file nodejs 
Javascript :: js propagation stop 
Javascript :: set multiple attributes css javascript 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =