Problem with key input?

so I’m trying to fix my keyboard input. Problem is, I’m getting :

Uncaught ReferenceError: Cannot access 'w' before initialization

Key code :

// Get Keyboard Cursor{s} Input
this.cursors = this.input.keyboard.createCursorKeys ( );

this.__keyList = {

    w : Phaser.Input.Keyboard.KeyCodes.W, 
    a : Phaser.Input.Keyboard.KeyCodes.A, 
    s : Phaser.Input.Keyboard.KeyCodes.S, 
    d : Phaser.Input.Keyboard.KeyCodes.D, 

};

this.__keys = ({
    w : w, 
    a : a, 
    s : s, 
    d : d, 
    up : up, 
    down : down, 
    left : left, 
    right : right, 
    space : space, 
    shift : shift, 
});

// Get Keyboard Key{s} Input
this.keys = this.input.keyboard.addKeys ( this.__keyList );

const

{

    left, right, up, 
    down, space, shift, 

} = this.scene.cursors;

const

{

    w, a, s, 
    d, 

} = this.scene.keys;

Any help as always is GREATLY appreciated! & Merry Christmas!

looks like

var a = { c: c}

but c is not defined

this.__keys = ({
   w:w,
   ....
})

where is w defined?

@cuihu : i do not understand. those are not lines in my source.

According https://github.com/photonstorm/phaser/blob/master/src/input/keyboard/KeyboardPlugin.js
I guess

this.__keys = ({
  w: 'w'
  ...
})

only guess

@cuihu : 'w' is defined in :

this.__keyList = {

    w : Phaser.Input.Keyboard.KeyCodes.W, 

it’s my fault
it’s shold like

var k = {c:c}
const c = 8

or

var k = {c:c}
let  c = 8

try replace const to var ?

Where do you use it? Because the values in the object are not defined anywhere. Even if defined in the snippet you provided they are out of scope. I mean the w, a, s etc values in the object.

If you say defined in this.__keyList reference them in this.__keys as this.__keyList.w etc.

Thanks, guys. I got it figured out by restoring a backup code I had from a month ago.

Here’s the solution :

This goes inside 'player-states.js' :

const

{

	left, right, up, 
	down, space, shift, 

} = this.scene.cursors;

const

{

	w, a, s, 
	d, 

} = this.scene.keys;

this.__keys = ({
	w : w, 
	a : a, 
	s : s, 
	d : d, 
	up : up, 
	down : down, 
	left : left, 
	right : right, 
	space : space, 
	shift : shift, 
});

This goes inside 'player.js' :

this.__keyList = 

{

	w : Phaser.Input.Keyboard.KeyCodes.W, 
	a : Phaser.Input.Keyboard.KeyCodes.A, 
	s : Phaser.Input.Keyboard.KeyCodes.S, 
	d : Phaser.Input.Keyboard.KeyCodes.D, 

}

// Get Keyboard Cursor{s} Input
this.cursors = this.input.keyboard.createCursorKeys ( );

// Get Keyboard Key{s} Input
this.keys = this.input.keyboard.addKeys ( this.__keyList );

Both go in the 'create ( )' function

Thanks again!

MERRY CHRISTMAS! <3