# Temporarily stop the player for a couple of seconds

**URL:** https://phaser.discourse.group/t/temporarily-stop-the-player-for-a-couple-of-seconds/7390
**Category:** Phaser 3
**Created:** [September 10, 2020, 6:18pm UTC](https://phaser.discourse.group/t/temporarily-stop-the-player-for-a-couple-of-seconds/7390 "2020-09-10T18:18:32Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jaybird](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jaybird](https://phaser.discourse.group/u/jaybird)
#### Post date: [September 10, 2020, 6:18pm UTC](https://phaser.discourse.group/t/temporarily-stop-the-player-for-a-couple-of-seconds/7390/1 "2020-09-10T18:18:33Z")

</div>

I want to temporarily stop the player from moving for a couple of seconds after it collides with an item in the game. I’ve added a function in a  
player class for that purpose and managed to disable the controls, but the player keeps moving after the collision.

Here is the function I wrote:

```
specialItemCollected()
	{
		
		
		this.scene.input.keyboard.enabled = false
		
		this.scene.time.delayedCall(2000, () => {
			this.scene.input.keyboard.enabled = true
		  }, [], this);

	}

```

The pictures illustrate the effect I want to achieve:

 ![Link_s_Awakening_trading_sequence_Magnifying_Glass_cover](https://global.discourse-cdn.com/free1/uploads/phaser1/original/2X/0/003c873e3e116a9e8f37429959ca271b1dc52cf2.jpeg) ![c6bcf0194d7c86284d5067429fc9a3d8430c017e_hq](https://global.discourse-cdn.com/free1/uploads/phaser1/original/2X/4/4715cf71e0c818b111147d4e5995d43c9dc40a0c.gif)

---

<div class="post-metadata">

### Author: ![BlunT76](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/blunt76/32/1454_2.png) [@BlunT76](https://phaser.discourse.group/u/BlunT76)
#### Post date: [September 10, 2020, 7:57pm UTC](https://phaser.discourse.group/t/temporarily-stop-the-player-for-a-couple-of-seconds/7390/2 "2020-09-10T19:57:32Z")

</div>

Hi

Try this syntax:

```javascript
this.scene.time.addEvent({
  delay: 2000,
  callback: () => {
    this.scene.input.keyboard.enabled = true
  }
});

```

---

<div class="post-metadata">

### Author: ![jaybird](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jaybird](https://phaser.discourse.group/u/jaybird)
#### Post date: [September 10, 2020, 8:22pm UTC](https://phaser.discourse.group/t/temporarily-stop-the-player-for-a-couple-of-seconds/7390/3 "2020-09-10T20:22:51Z")

</div>

No that didn’t work. The player keeps moving even though I release the arrow key after the collision 🙃

However, I solved it by adding a boolean variable called isPlayerMovable which by default is true:

```
foundItem()
	{
		
		this.isPlayerMovable = false
		
			
		this.scene.time.delayedCall(2000, () => { 

			this.isPlayerMovable = true

		}, [], this);

	}

...

update(cursors: Phaser.Types.Input.Keyboard.CursorKeys)

    {
...
if (this.isLeftKeyDown && this.isPlayerMovable)

  {...}

}
```
