Commit 5467a97a by Benjamin Gallois

Better key options

parent 3ec4879c
......@@ -18,20 +18,21 @@ function move(){
}
body.style.left = x + 'px';
body2.style.left = x2 + 'px';
moveInterval = setTimeout(move, 12);
}
window.addEventListener("keyup", function(event) {
window.addEventListener("keydown", function(event) {
event.preventDefault();
if (event.keyCode === 27) {
window.location.href = 'main.html';
}
if (event.keyCode === 13) {
if (stop){
moveInterval = setInterval(move, 10);
moveInterval = setTimeout(move, 10);
stop = false;
}
else if (!stop) {
clearInterval(moveInterval);
clearTimeout(moveInterval);
stop = true;
}
}
......@@ -39,10 +40,10 @@ window.addEventListener("keyup", function(event) {
velocity =- velocity;
}
if (event.keyCode === 39) {
velocity += 0.1;
velocity += Math.sign(velocity)*1;
}
if (event.keyCode === 37) {
velocity -= 0.1;
velocity -= Math.sign(velocity)*1;
}
if (event.keyCode === 38) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment