Skip to content

Instantly share code, notes, and snippets.

@Beneboe
Created January 29, 2013 19:22
Show Gist options
  • Save Beneboe/4666855 to your computer and use it in GitHub Desktop.
Save Beneboe/4666855 to your computer and use it in GitHub Desktop.
comes in handy when working with html5 canvas
var keyPressed;
document.onkeyup = function(event) {
keyPressed = String.fromCharCode(('which' in event) ? event.which : event.keyCode);
input();
};
function input() {
if(keyPressed == "D") document.write("hi");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment