_input Method: Handle Multiple inputs at once

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Marteon27
:warning: Old Version Published before Godot 3 was released.

I want to handle two inputs: left and right. But it seems that the _input
method from Node cant handle them.
So here is my scenario: When I press right my Character walks to the right; when I then press left (and keep right pressed) my Character walks to the left, which shouldn’t happen since I press left and right and the movements should eliminate each other.

func _input(event):
	velocity.x -= WALK_SPEED

	velocity.x += WALK_SPEED

It seems like the _input method is only called for the last key pressed.
Is this normal? And how to get around this to have multiple inputs at once.

:bust_in_silhouette: Reply From: Zylann

Yes, it is normal.
Check my answer to this similar question: Input detection problem - Archive - Godot Forum

Thank you for your quick reply!

Marteon27 | 2017-05-11 11:23