Created
February 12, 2014 16:37
-
-
Save btipling/8959266 to your computer and use it in GitHub Desktop.
This file contains 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 f = document.body.onkeydown; | |
var flyStraight = 700; | |
var flyDown = 800; | |
var flyUp = 500; | |
var current = 500; | |
function run () { | |
window.setTimeout(function () { | |
console.log("current", current); | |
f(); | |
run(); | |
current = flyStraight; | |
}, current); | |
} | |
run(); | |
function handle (evt) { | |
console.log("got key", evt.keyCode); | |
// "u" | |
if (evt.keyCode === 85) { | |
console.log("flying down"); | |
current = flyDown; | |
} | |
// "d" | |
if (evt.keyCode === 68) { | |
current = flyUp; | |
console.log("flying up"); | |
} | |
} | |
document.body.onkeydown = handle; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment