0

keyboard in JavaScript

how to cause to page internet to respond when I click on the darts in keyboard? for example in games. sorry because the my Henglish I spick Hebrew

20th Aug 2017, 3:56 PM
cbhnhifudi
cbhnhifudi - avatar
2 Réponses
+ 1
with Jquery ,since you tagged it : $(window).keydown(function(event) { if (event.keyCode == 37) { \\doSomething} } Instead of window you can use any DOM element; Instead of 37 you can use any KeyCode you need. You can check KeyCodes here: https://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes Or you can use my snippet to check KeyCode you need by yourself. var body = document.querySelector('body'); body.onkeyup = function(e) { console.log(e.keyCode) }; With this thing just when you'll press any keyboard button - console will show it's KeyCode.
20th Aug 2017, 4:11 PM
Rose Sevenyears
Rose  Sevenyears - avatar
0
thank you
20th Aug 2017, 4:14 PM
cbhnhifudi
cbhnhifudi - avatar