Skip to content

Instantly share code, notes, and snippets.

@Canx
Created November 25, 2013 10:01
Show Gist options
  • Save Canx/7639084 to your computer and use it in GitHub Desktop.
Save Canx/7639084 to your computer and use it in GitHub Desktop.
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