Phaser.Key = function (game, keycode){ this.game = game; this.isDown = false ; this.isUp = false ; this.altKey = false ; this.ctrlKey = false ; this.shiftKey = false ; this.timeDown = 0; this.duration = 0; this.timeUp = 0; this.repeats = 0; this.keyCode = keycode; this.onDown = new Phaser.Signal(); this.onUp = new Phaser.Signal(); } ; Phaser.Key.prototype = { processKeyDown: function (event){ this.altKey = event.altKey; this.ctrlKey = event.ctrlKey; this.shiftKey = event.shiftKey; if (this.isDown) { this.duration = event.timeStamp - this.timeDown; this.repeats++ ; } else { this.isDown = true ; this.isUp = false ; this.timeDown = event.timeStamp; this.duration = 0; this.repeats = 0; this.onDown.dispatch(this); } } , processKeyUp: function (event){ this.isDown = false ; this.isUp = true ; this.timeUp = event.timeStamp; this.onUp.dispatch(this); } , justPressed: function (duration){ if (typeof duration === "undefined") { duration = 250; } return (this.isDown && this.duration < duration); } , justReleased: function (duration){ if (typeof duration === "undefined") { duration = 250; } return (this.isDown === false && (this.game.time.now - this.timeUp < duration)); } } ;