BlueLemming Posted January 29, 2018 Share Posted January 29, 2018 I've been struggling to figure out if the "_justDown" property of a key is working properly or not. It seems to always be true as long as the key is held just like "isDown" when accessed directly (ex: someKey._justDown). It seems that the intention is to use the Phaser.Input.Keyboard.JustDown() getter method, but it returns the same results as key.isDown and key._justDown (ex: Phaser.Input.Keyboard.JustDown(someKey)) If this is a bug then I'm comfortable enough to try and make a fix, but I figured I should first see if I'm misunderstanding how to use it in the first place. (Using Phaser 3 beta 19) Link to comment Share on other sites More sharing options...
BlueLemming Posted February 4, 2018 Author Share Posted February 4, 2018 I was able to make my own quick solution for detecting when a key was first pressed. I used lodash for a helper function, apologies if you don't want to use lodash. You'll just have to rewrite the "getKeyByKeycode" function if so. // snipped from my ES6 Scene class import _find from 'lodash/find' export default class extends Phaser.Scene { create() { this.keys = this.input.keyboard.addKeys({ left: Phaser.Input.Keyboard.KeyCodes.LEFT, right: Phaser.Input.Keyboard.KeyCodes.RIGHT, jump: Phaser.Input.Keyboard.KeyCodes.A }) this.input.keyboard.on('keydown', event => { const key = this.getKeyByKeyCode(event.keyCode) if (key) { if (key.timeUp === 0 || key.timeDown < key.timeUp) { if (key.timeUp === 0) { key.timeUp = 1 } this.input.keyboard.emit('keypressed', event) } } }) } getKeyByKeyCode(keyCode) { return _find(this.keys, { keyCode }) } } Link to comment Share on other sites More sharing options...
jorbascrumps Posted February 18, 2018 Share Posted February 18, 2018 @BlueLemming I'm having the same issue and I'm wondering if this is an oversight. Would it be possible to provide some insight on this, @rich? Link to comment Share on other sites More sharing options...
Recommended Posts