[ACCEPTED]-Javascript: addEventListener with onkeydown doesn't seem to work-javascript
Accepted answer
The event type should be "keydown"
, notice that 3 you don't need the on prefix:
element.addEventListener("keydown", keyDownTextField, false);
Note also that 2 you should get the keyCode
from the event object 1 in your handler:
function keyDownTextField (e) {
var keyCode = e.keyCode;
//...
}
Check an example here.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.