There's a bug around character movement with arrow keys. The current onkeydown function will run the movement code for any key pressed as long as one of the arrow keys is pressed. This results in the movement code running per key pressed, effectively multiplying the characters movement speed by the number of keys pressed.
You can see this is a the live demo. If you click an arrow key + any other key, movement speed doubles and increases for each key pressed.
Suggested fix:
adding a guard to prevent movement code from running if the key pressed is not a direction like this:
if (!directions.includes(key)) return
There's a bug around character movement with arrow keys. The current onkeydown function will run the movement code for any key pressed as long as one of the arrow keys is pressed. This results in the movement code running per key pressed, effectively multiplying the characters movement speed by the number of keys pressed.
You can see this is a the live demo. If you click an arrow key + any other key, movement speed doubles and increases for each key pressed.
Suggested fix: adding a guard to prevent movement code from running if the key pressed is not a direction like this:
if (!directions.includes(key)) return