LastPressedKey() Not Detecting Fast Consecutive Keypresses

How do I…

I want to detect multiple keypresses in quick succession using the LastPressedKey() function. However, whenever I press two keys nearly at the same time, the second key is never detected—it seems like there’s a delay causing the “last key” to remain the first one pressed.

What is the expected result

I expect that every time I press a key, LastPressedKey() should update immediately—even if two keys are pressed quickly one after the other—so that the game accurately tracks the most recently pressed key.

What is the actual result

Instead, if I press a key and then press another key almost simultaneously, LastPressedKey() still returns the previous key instead of the most recent one.

Related screenshots

Project files (optional)

If you need to see a specific setup, let me know—I can provide a minimal project where pressing two keys quickly doesn’t trigger the second key to be recognized by LastPressedKey().

Hmm… I think for what you’re trying to do you would be much better off using the “Any key pressed” condition, instead of your current string key pressed condition checking lastkeypressed(). You’d leave the rest of your event as is

That said; As far as I know, events can only happen once per frame. Anything that happens more than once per frame won’t get detected. I would imagine the issue is that you’re releasing it and pressing the new key after the frame has started, and so the “trigger once” is never getting reset.

There’s no alternatives for that just due to event logic only occurring once per frame. Changing the above condition should at least prevent some issues, but won’t over

Also note: A tween by a specific name can be running one at any given time, your tween will likely run into numerous issues because it won’t be finished until 0.5 seconds have ended (about 30 frames), and you’re trying to start it over again with the next key pressed already.

1 Like

Thanks so much for the explanation—this is really helpful! I hadn’t considered using the “Any key pressed” condition, so I’ll definitely switch to that. As for my tween logic, I realize now I don’t have any conditions checking whether the old tween has finished before starting a new one. I’ll add that in so I can properly manage when the tween ends and a new one can begin without overlapping or canceling. Really appreciate the guidance!