Created
November 25, 2013 10:01
-
-
Save Canx/7639084 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var teclas = { 32: false, 33: false, 34: false }; | |
document.addEventListener("keydown", function(event) { | |
teclas[event.keyCode] = true; | |
}); | |
document.addEventListener("keyup", function(event){ | |
teclas[event.keyCode] = false; | |
}); | |
function comprobarTeclas() { | |
for(var tecla_actual in teclas) { | |
if (teclas[tecla_actual]) { | |
accion(tecla_actual); | |
} | |
} | |
setTimeout(comprobarTeclas, 100); | |
} | |
function accion(codigo_tecla) { | |
console.log("tecla accion:" + codigo_tecla); | |
} | |
comprobarTeclas(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment