yahiko Posted June 27, 2017 Share Posted June 27, 2017 Hi, In a menu state of mine, instead of pressing spacebar, I would like to let the player press any key to continue. What would be the best way to detect if any key is pressed? Link to comment Share on other sites More sharing options...
PhasedEvolution Posted June 27, 2017 Share Posted June 27, 2017 Well, pure javascript? document.body.addEventListener('keypress', yourFunction); yahiko 1 Link to comment Share on other sites More sharing options...
yahiko Posted June 27, 2017 Author Share Posted June 27, 2017 Hmm, yes... But is there a way to do that in Phaser? without addEventListener? Link to comment Share on other sites More sharing options...
rockleaf99 Posted June 27, 2017 Share Posted June 27, 2017 game.input.keyboard.onPressCallback = function(e){console.log("key pressed", e);} This can be used to detect keyboard button presses. I would set it back to null when not at the menu screen so that it doesn't fire all the time. http://phaser.io/docs/2.4.6/Phaser.Keyboard.html yahiko and vastron 2 Link to comment Share on other sites More sharing options...
Recommended Posts