# Event handlers not working

**URL:** <https://phaser.discourse.group/t/event-handlers-not-working/2975>\
**Category:** Phaser 3\
**Created:** [July 3, 2019, 1:12am UTC](https://phaser.discourse.group/t/event-handlers-not-working/2975 "2019-07-03T01:12:10Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![keithleon](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/keithleon/32/1647_2.png) [@keithleon](https://phaser.discourse.group/u/keithleon)\
**Post date:** [July 3, 2019, 1:12am UTC](https://phaser.discourse.group/t/event-handlers-not-working/2975/1 "2019-07-03T01:12:11Z")

</div>

Hello, for some reason I can’t seem to get any of the `this.input.on` event handlers to work. They seem to just do nothing for me.

```
 this.input.on('pointermove', function(pointer){
     //....
 })
```

---

<div class="post-metadata">

**Author:** ![prob](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/prob/32/628_2.png) [@prob](https://phaser.discourse.group/u/prob)\
**Post date:** [July 3, 2019, 2:14pm UTC](https://phaser.discourse.group/t/event-handlers-not-working/2975/2 "2019-07-03T14:14:09Z")

</div>

That’s the correct event (although you should use Phaser.Input.Events.POINTER\_MOVE). Is the code you posted in the scene’s create() function?

---

<div class="post-metadata">

**Author:** ![keithleon](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/keithleon/32/1647_2.png) [@keithleon](https://phaser.discourse.group/u/keithleon)\
**Post date:** [July 3, 2019, 3:59pm UTC](https://phaser.discourse.group/t/event-handlers-not-working/2975/3 "2019-07-03T15:59:30Z")

</div>

@prob yeah it just seems to do nothing. I can’t even get a console.log or anything out it. It doesn’t throw an error. it just never fires.

how would i use `Phaser.Input.Events.POINTER_MOVE` ?

P.S.  
I’m on current version of phaser 3 (3.18.1)

---

<div class="post-metadata">

**Author:** ![Jake.Caron](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/jake.caron/32/1841_2.png) [@Jake.Caron](https://phaser.discourse.group/u/Jake.Caron)\
**Post date:** [July 3, 2019, 4:46pm UTC](https://phaser.discourse.group/t/event-handlers-not-working/2975/4 "2019-07-03T16:46:25Z")

</div>

`Phaser.Input.Events.POINTER_MOVE` is just a global variable with a value of `'pointermove'`. So your function of:

```javascript
this.input.on('pointermove', function(pointer){
     //....
 })

```

turns into:

```javascript
this.input.on(Phaser.Input.Events.POINTER_MOVE, function(pointer){
     //....
 })

```

It’s not 100% required, as even Rich, the creator of phaser, uses the string literals all the time. However, it is good practice in case the event name ever gets changed and you update your project.

As far as your problem is concerned, can you supply us with a whole block of code with this issue isolated?

---

<div class="post-metadata">

**Author:** ![keithleon](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/keithleon/32/1647_2.png) [@keithleon](https://phaser.discourse.group/u/keithleon)\
**Post date:** [July 3, 2019, 4:58pm UTC](https://phaser.discourse.group/t/event-handlers-not-working/2975/5 "2019-07-03T16:58:23Z")

</div>

ah gotcha. so even something like:

```
function create() {
 //...
      this.input.on(Phaser.Input.Events.POINTER_MOVE, function(pointer){
        console.log('test')
      })
}

```

just does nothing. i’m frankly baffled as to why.  
here is my config if that helps.

```
const config = {
  title: "Keith Leon",
  banner: false,
  pixelArt: true,
  backgroundColor: 0xffffff,
  type: Phaser.AUTO,
  parent: "game",
  physics: {
    default: 'arcade',
    arcade: {
        gravity: { y: 300 },
        debug: false
    }
  },
  autoCenter: true, 
  scale: {
    mode: Phaser.Scale.FIT,
    autoCenter: Phaser.Scale.CENTER_BOTH,
    parent: 'game',
    width: '100%',
    height: '100%'
  },
  scene: {
    preload: preload,
    create: create,
    update: update
  },
  audio: {
    noAudio: true
  }
};
```

---

<div class="post-metadata">

**Author:** ![Jake.Caron](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/jake.caron/32/1841_2.png) [@Jake.Caron](https://phaser.discourse.group/u/Jake.Caron)\
**Post date:** [July 3, 2019, 6:52pm UTC](https://phaser.discourse.group/t/event-handlers-not-working/2975/6 "2019-07-03T18:52:59Z")

</div>

I went over to [https://labs.phaser.io/edit.html](https://labs.phaser.io/edit.html) and pasted your code and it works as expected. The problem must be somewhere else in your project.

```javascript
const config = {
  title: "Keith Leon",
  banner: false,
  pixelArt: true,
  backgroundColor: 0xffffff,
  type: Phaser.AUTO,
  parent: "game",
  physics: {
    default: 'arcade',
    arcade: {
        gravity: { y: 300 },
        debug: false
    }
  },
  autoCenter: true, 
  scale: {
    mode: Phaser.Scale.FIT,
    autoCenter: Phaser.Scale.CENTER_BOTH,
    parent: 'game',
    width: '100%',
    height: '100%'
  },
  scene: {
    create: create
  },
  audio: {
    noAudio: true
  }
};
var game = new Phaser.Game(config);

function create() {
      this.input.on(Phaser.Input.Events.POINTER_MOVE, function(pointer){
        console.log('test')
      })
}

```

---

<div class="post-metadata">

**Author:** ![keithleon](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/keithleon/32/1647_2.png) [@keithleon](https://phaser.discourse.group/u/keithleon)\
**Post date:** [July 3, 2019, 7:13pm UTC](https://phaser.discourse.group/t/event-handlers-not-working/2975/7 "2019-07-03T19:13:08Z")

</div>

ah what a cool tool. so thanks for the help this lead me to figuring out my issue.

i have some weird things going on for my purposes and i have this set in CSS to push the canvas to the back of the page

```
canvas{
    z-index: -10;
    position: fixed;
}

```

turns out the `z-index: -10` property here prevents the canvas from detecting the pointer moving. it still picks up the pointer clicking, but it can’t track its movement or even detect something like `pointerdown`.

Weird. thank you so much!

---

<div class="post-metadata">

**Author:** ![tdgao](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/tdgao/32/7797_2.png) [@tdgao](https://phaser.discourse.group/u/tdgao)\
**Post date:** [May 6, 2024, 3:00pm UTC](https://phaser.discourse.group/t/event-handlers-not-working/2975/8 "2024-05-06T15:00:41Z")

</div>

To add to this thread for future devs

For me, `position: static;` had weird behavior with the mouse move event when combined to create camera drag.

Changing to `position: relative;` fixes it. Hope it helps someone!
