Skip to content

Instantly share code, notes, and snippets.

@philhawksworth
Created September 7, 2012 13:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save philhawksworth/3666283 to your computer and use it in GitHub Desktop.
Save philhawksworth/3666283 to your computer and use it in GitHub Desktop.
control = {
32 : go_up,
46 : go_down
};
$(document).bind("keydown", function(e) {
console.log("keydown: ", e.keyCode);
if(!control[e.keyCode]) {
return;
}
control[e.keyCode].call();
});
function go_up() {
alert("UP");
}
function go_down() {
alert("DOWN");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment