You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.1 KiB

2 years ago
window.onkeydown = function(e){
var key = e.keyCode ? e.keyCode : e.which;
if (instructionsOpen){
if (key == ESCAPE){
closeInstructions();
e.preventDefault();
}
return;
}
switch (key) {
case ESCAPE:
e.preventDefault();
closeInfo(null);
break;
case TAB:
e.preventDefault();
openInfo(null);
break;
case 32: //Space
e.preventDefault();
if (currentGame.isPaused){
currentGame.pause(false);
} else if (currentGame.isStarted && !currentGame.isPaused) {
currentGame.pause(true);
}
if (!currentGame.isStarted){
currentGame.start();
}
break;
case SHIFT:
e.preventDefault();
if (keyIsDown(68)){
//Shift + D
deleteMemory();
} else if (keyIsDown(82)){
//Shift + R
currentGame.restart();
} else if (keyIsDown(78)){
//Shift + N
toggleNotifications();
}
break;
case 68: //D
e.preventDefault();
if (keyIsDown(SHIFT)){
//D + Shift
deleteMemory();
}
break;
case 82: //R
e.preventDefault();
if (keyIsDown(SHIFT)){
//R + Shift
currentGame.restart();
}
break;
}
}