tsphillips Posted September 21, 2015 Share Posted September 21, 2015 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 More sharing options...
mcolman Posted September 21, 2015 Share Posted September 21, 2015 This worked for me.https://gist.github.com/mattcolman/493c216211edc87bc8e9 Link to comment Share on other sites More sharing options...
RaphaelStary Posted September 21, 2015 Share Posted September 21, 2015 to change or prevent default browser behavior like,'go back' with 'backspace' or'submit' with 'enter' orgestures 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 Tilde 1 Link to comment Share on other sites More sharing options...
Recommended Posts