+ 2
How can i call the event onkeypress in a div?
2 Respostas
+ 2
Hey! Onkeypress has been deprecated, you can use onkeydown instead.
Let's say that the div has a 'div1' id, here's how to do it:
document.getElementById('div1').addEventListener('keydown', function() {
//your code goes here
}
+ 1
You can add any attribute to the elememt itself.
<div onkeyup="function()"></div>