keypress javascript
snippet in javascript

keypress javascript

user5673

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 !)

js when key is pressed

user9789

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

html onkeypress

user689

<input type="text" onkeypress="myFunction()">