Keyboard, last Key pressed

Hi @ll,

I can’t find a function for the last key was pressed.

Example:

this.controls.left = !!(this.keys.left.isDown || this.wasd.left.isDown);
this.controls.right = !!(this.keys.right.isDown || this.wasd.right.isDown);
this.controls.up = !!(this.keys.up.isDown || this.wasd.up.isDown);
this.controls.down = !!(this.keys.down.isDown || this.wasd.down.isDown);

if (this.controls.left) {
this.playerDirection = left;
} else if (this.controls.right) {
this.playerDirection = right;
} else if (this.controls.up) {
this.playerDirection = up;
} else if (this.controls.down) {
this.playerDirection = down;
}

User pressed UP and then LEFT (Combo)
The last pressed Key is LEFT

this.playerDirection = lastKeyWasPressed?;

I can save the Data in Array/Object and then compare.
But, i hope someone has a different Solution

Phaser already has key combos functionnality, sorry i don’t remember the exact name of the method, but you can find it with the doc