Spacebar blocks input/Optimal movment code solution?

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

Hi.

I noticed that pressing a key and a spacebar prevents engine from receiving input from another one. It seems to be some kind of a deeper problem, as it persists even in official demos like “Simple Shooter”.
For example: Pressing space, left arrow and then upper arrow will move the spaceship left but not up until spacebar is released. Removing spacebar for input mappings doesn’t solve it.

Is this an known issue and how to go around it? I don’t think not using spacebar is the solution. Could it be that movement code from the demos is not a fully functional approach?

Here it is for reference:

 if Input.is_action_pressed("up"):
      #do stuff
 if Input.is_action_pressed("down"):
      #do stuff
 if Input.is_action_pressed("left"):
      #do stuff
 if Input.is_action_pressed("right"):
      #do stuff

If so how to do it properly? Thank you.

Do you have this problem if you poll input directly with Input.is_key_pressed(KEY_SPACE) etc?

Zylann | 2017-11-28 12:32

Yes I do. Just checked, no doubt.

MAJOR_KONTROL | 2017-11-28 13:28

What is your OS? Which Godot version? I know that some keyboards have a limit on the number of keys you can press at the same time.

I tested this in Godot 2.1.3:

func _process(delta):
	var keys = ""
	if Input.is_key_pressed(KEY_LEFT):
		keys += "L"
	if Input.is_key_pressed(KEY_RIGHT):
		keys += "R"
	if Input.is_key_pressed(KEY_UP):
		keys += "U"
	if Input.is_key_pressed(KEY_DOWN):
		keys += "D"
	if Input.is_key_pressed(KEY_SPACE):
		keys += "S"
	print(keys)

All keys registered correctly, even if I press them all.
Also make sure you really mean “real” input, because if you deduce this by looking at character movement in the game, then it could simply be that one if blocks simply takes over the state decided in the previous if block, which is not a Godot bug but a game “bug”.

Zylann | 2017-11-28 19:56

Win 7 x64 - Godot 2.1.4.
Tested your code. It won’t register certain combinations. It’s really strange.
For example:
Right + Up + Space works
Left + Up + Space doesn’t
But if during this combination, I switch from holding Right to holding Left key, it will still register R + U + S until I release one of the keys.

MAJOR_KONTROL | 2017-11-29 22:02

Your keys work in the keyboard test application on this page?

https://www.microsoft.com/appliedsciences/KeyboardGhostingDemo.mspx

If not, is ghosting.

eons | 2017-11-29 23:42

I finally read your reply. Thank you very much. Quite fascinating. Problem solved.

MAJOR_KONTROL | 2017-12-06 22:41

Is something really annoying on the developer side because you do not know how good or bad will be the average keyboard of the players.

An option is to allow key configuration and add support for gamepads (is a plus for accessibility).

eons | 2017-12-06 23:33

:bust_in_silhouette: Reply From: MAJOR_KONTROL

Seems to be a case of ghosting. Problem was on my end.