# How to create pause/resume key?

**URL:** <https://phaser.discourse.group/t/how-to-create-pause-resume-key/9513>\
**Category:** Phaser 3\
**Created:** [May 10, 2021, 6:24am UTC](https://phaser.discourse.group/t/how-to-create-pause-resume-key/9513 "2021-05-10T06:24:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![benanson](https://avatars.discourse-cdn.com/v4/letter/b/5f8ce5/32.png) [@benanson](https://phaser.discourse.group/u/benanson)\
**Post date:** [May 10, 2021, 6:24am UTC](https://phaser.discourse.group/t/how-to-create-pause-resume-key/9513/1 "2021-05-10T06:24:44Z")

</div>

Hello everyone  
How to create pause/resume key using Phaser 3?

here is my code:

```
function create(){
     this.pause = false;
     this.input.enabled = true;
     this.keyPause = this.scene.input.keyboard.addKey("P");
    }

function update(){
  if(this.keyPause.isDown){
      if(this.pause){
         this.pause = false;
         this.scene.resume();
      }else{
         this.pause = true;
         this.scene.pause();
      }
    }
}

```

it is scucessful to pause the game, but fail to resume the game.

Anyidea??? Thank you very much

---

<div class="post-metadata">

**Author:** ![Milton](https://avatars.discourse-cdn.com/v4/letter/m/87869e/32.png) [@Milton](https://phaser.discourse.group/u/Milton)\
**Post date:** [May 10, 2021, 7:01am UTC](https://phaser.discourse.group/t/how-to-create-pause-resume-key/9513/2 "2021-05-10T07:01:43Z")

</div>

#### pause( [key] [, data])

Pause the Scene - **this stops the update step from happening** but it still renders.

So either use another scene, or just skip code yourself, like

```javascript
update() {
    if (Phaser.Input.Keyboard.JustDown(keyPause)) this.pause = !this.pause;
    if (this.pause) return;

    ...
}

```
