Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Browser Eats Backspace (Phaser.Keyboard.BACKSPACE)


tsphillips
 Share

Recommended Posts

I am capturing keyboard input, and one of the keys I need to handle is backspace.  Everything works fine in Phaser, until . . . the browser also sees that backspace was pressed and interprets it as me pressing the back button in the browser.  I am seeing this behavior in Chrome and Firefox.

 

Ideally, the only element under the body element should be the div holding the canvas.  Is there a quick, easy, and portable/reliable method to ensure the browser does not act on the backspace key?

 

 

 

Link to comment
Share on other sites

to change or prevent default browser behavior like,
'go back' with 'backspace' or
'submit' with 'enter' or
gestures with touch events,

the best way is, to use the method 
event.preventDefault(); (use it in your event listener eg. keydown listener etc)
https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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