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
2 Respostas
+ 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.
0
thank you