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

keypress event

document.addEventListener("keypress", function(e) {
	e = e || window.event;
	// Add scripts here
	e.keyCode; // -> returns the keycode of the key that triggered the event
	e.key.toString(); // -> returns the ASCII character of the key that triggered the event
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: react native text input right 
Javascript :: javascript insert item into array 
Javascript :: json javascript 
Javascript :: js clone deep 
Javascript :: vue get element height 
Javascript :: clear input field jquery 
Javascript :: insert data from lambda to dynamodb 
Javascript :: javascript find 
Javascript :: react on focus out 
Javascript :: month list javascript 
Javascript :: jquery select attribute 
Javascript :: react disable eslint errors 
Javascript :: discord.js how to edit a message 
Javascript :: how to check if window is loaded javascript 
Javascript :: js number with four decimal places 
Javascript :: jsx foreach 
Javascript :: es6 map usin index 
Javascript :: search inside a string javascript 
Javascript :: To split a full name into first and last names in JavaScript 
Javascript :: node.js f string 
Javascript :: javascript random integer 
Javascript :: run a code after delay js 
Javascript :: javascript element read attribute 
Javascript :: react history go back 
Javascript :: how to find whether empty or not using jQuery 
Javascript :: find longest word in string javascript 
Javascript :: jquery ajax 500 error handling 
Javascript :: javascript check if argument is passed 
Javascript :: set date to input date js 
Javascript :: event.target data-target 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =