Javascript functions only partially working

Sorry for the vague title, wasn't sure how to structure the title for this one.

I'm building a game for my JS class project. And there are code I've written that make sense to me but doesn't work right when implemented and was wondering if I could get some insight.

FIRST PART HAS BEEN SOLVED THANKS TEAM! PLEASE READ FURTHER TO HELP OUT WITH THE SECOND PART!

function goStraight(){
if (transition == 0){
    return;
}
if (transition == 1){
    ctx.clearRect (0,0,500,500);
    ctx.beginPath();
    ctx.drawImage (blankPage,0,0);
    continueGame = prompt("You have made it to the boss room, a powerful being with a lot of power: If you wish to continue type 'continue' if you wish to turn back and end your journey here type 'exit' !");
        while (continueGame !== "continue" && continueGame !== "exit"){
        continueGame = prompt("You have made it to the boss room, a powerful being with a lot of power: If you wish to continue type 'continue' if you wish to turn back and end your journey here type 'exit' !");
        }
    if (continueGame == "continue"){
        ctx.clearRect (0,0,500,500);
        ctx.beginPath();
        ctx.drawImage (takeThis,0,0);
        transition = 4;
        return;
        }
    if (continueGame == "exit"){
        startGame();
        return;
        }
}

The second part of this I'm having issue with is the "exit" part. If I execute the "exit" if statement it runs the starGame() function which is:

function startGame(){
ctx.clearRect (0,0,500,500);
ctx.beginPath();
ctx.drawImage (start,0,0);
transition = 0;
continueGame = 0;
document.getElementById("intro").onkeydown = function enterToStart(event){
if (event.keyCode === 13) {
    centerRoom();
    return;
      }
   }
}

but when I try and press "enter" to start the game again it brings up the prompt from goStraight() which all I can gather from that is for some reason the function is still called when I press enter since enter is supposed to make transition = 1 and the prompt should only come up when transition = 1.

Sorry again for the long winded question.