Jump to content

re-enabling browser key events


OpherV
 Share

Recommended Posts

I'm using game.input.keyboard.addKey to capture some input, which works great.

However, I'm using some HTML forms for menus, and the keys mapped to phaser don't work in those (because I assume phaser stops the key event propagation).

 

Is there a way to disable the phaser key capture while my form is open and return the key event propagation, then re-enable it when I close my form?

 

I tried myKey.enabled=false, but that only disables the key, it doesn't re-enable it for the browser.

Link to comment
Share on other sites

So to answer my own question:

 

To disable game capture and return control to the browser-

Phaser.Keyboard.removeKeyCapture(myKey.keyCode);myKey.enabled=false;

to reenable:

Phaser.Keyboard.addKeyCapture(myKey.keyCode);myKey.enabled=true; 
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...