Jump to content

Disable backspace default


Taggrin
 Share

Recommended Posts

I am making a game where the player is required to write down stuff. Obviously you should be able to correct your mistakes using backspace. The game has no canvas textbox or whatsoever. It just globally catches A-Z, 0-9, space, enter and backspace to append (or remove if backspace) to a text variable in the game. This all works like a charm, except for the problem that backspace does work on file:// but once moving to http:// it will go to the previous browser session. Backspace should be disabled in that manner, but phaser should still be able to catch it for the game.

I looked through these and several other forums and found these two possible solutions. However, they do not work for me (no error, backspace just still goes to previous session). Any suggestions?

In HTML:

<script type="text/javascript">
   $(document).bind("keydown", function (e) {
      if (e.keyCode == 8) {
         e.preventDefault()
      }
   }
</script>

In create function of game:

this.input.keyboard.removeKeyCapture(Phaser.Keyboard.BACKSPACE);

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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