+ 1
Make a key perform an action when preseed?
Hey Sololearn community! I was trying to make a game in javascript but could not figure out how to make a command run when a key is pressed. Example: When the âAâ key is pressed, execute an alert function. Thanks!
4 RĂ©ponses
+ 1
Qyther i tried it and it did not work for me :(
0
ooh that is simple, just add this: HTML < <input type="text" onkeydown="checker(event)"> > JS < function checker(e) { var key = e.keyCode; if (key === 229) { alert("A key pressed!"); } }
EDIT: The keycode isn't actually 65! its 229!
0
heya! look at the edit