I want to disable CTRL + S
in the browser, so I can save my game, but it doesn't work.
The code looks like this right now:
document.addEventListener("keydown", function(event) {
if (event.ctrlKey && event.which == 83) { // ctrl + s
event.preventDefault();
saveGame();
}
}, false);
The code for saveGame()
is the following:
function saveGame() {
var gameSave = {
score: score,
clickingPower: clickingPower,
costGoku: costGoku,
gokus: gokus,
costVerbalase: costVerbalase,
verbalases: verbalases,
costSkyview: costSkyview,
skyviews: skyviews
};
localStorage.setItem("gameSave", JSON.stringify(gameSave));
}
The saveGame()
function works perfectly fine, but I still wanted to provide it so you can see what it does for clarification. When I press CTRL + S on my website it still wants to save the page and is not saving the game.