Stuttering keyboard input when holding a key pressed down

Hello fellow game developers :slight_smile:

When I press and hold a keyboard button to move Pawns their movement is stuttered.

To demostrate the issue I’ve configured the simple Axis Mapping for a “W” key that prints the input argument’s value:

void ASomePawn::MoveForward(float input) {
	UE_LOG(LogTemp, Warning, TEXT("%f"), input);
}
void ASomePawn::SetupPlayerInputComponent(UInputComponent* c) {
	Super::SetupPlayerInputComponent(c);
	c->BindAxis(TEXT("MoveForward"), this, &ABird::MoveForward);
}

The Axis Mapping itself works fine. Here is the shortened log of input to MoveForward function calls while I press, holding down, and finally release the “W” key on my keyboard: 00000000000000011111111111111111101010010001000101001011010011011100000000000000

As you can see from the log, after I press the “W” key for ~0.4sec the input is consistently “1”, but then it starts jumping between “0” and “1” until I finally release the “W” key when it turns to all “0” again.

I conducted some investigation and here are my findings related to this stuttering.

The stuttering occurs:

  • independently of whether I use deprecated or Enhanced input system;
  • even if I simply create and play a new “3rd person template” project;
  • in all play modes (PIE, new editor window, standalone game);
  • with the default pawn too.

And there is no stuttering if:

  • I click any other keyboard key while holding “W” before the stuttering starts, or even after it starts effectively eradicating the stuttering;
  • I map to left mouse button instead of the “W” key;
  • I use “W” to move default pawn in the editor;
  • I use any other application or game on my system.

I found similar issues on the internet, but they didn’t help me to solve the issue:

I tried to fiddle with Windows keyboard input configurations but wasn’t able to solve the issue.
I even tried to apply a “Smooth” modifier for my Enhanced input Mapping, it didn’t help too.
My keyboard doesn’t seem to have any input timing configurations either. I suppose the issue really may be with the keyboard, but I cannot get my hands on another keyboard for now to test this. And even if the keyboard is a culprit, what will I say to a player owning such a keyboard who cannot enjoy my UE games?

So, does anyone have any ideas how to solve this? I would really like to get some advice on my issue. I’m working on Windows 10, UE5.1 if it helps in any way.

Best regards.

Hey @PLone
are you using a wireless keyboard?

Hey @L1z4rD89
No, I’m using a mostly regular USB-keyboard.

@PLone Try posting a minimized project with the problem on google drive / one drive and see if it occurs on other people’'s pcs on the forum.

Here is the minimized UE5.1 project to reproduce the issue:

To reproduce the issue just open the project, play, and ensure the viewport has a keyboard focus. The project prints “0” and “1” on screen depending on whether the “W” key is pressed. By default it prints “0”. If you hold down the “W” it will print “1”. Hold down the “W” for a few seconds. After ~half a second of pressing down the “W” a stable sequence of “1” will become an unexpected mixture of “0” and “1”.

This is a really simple project. And I expect that anyone who didn’t encounter this stuttering problem earlier will not find any problems while running this project too. I really want to find people who had this problem and managed to solve it :). But, well, try running it.

And thanks to this idea of sharing the project, it occured to me that although I don’t have a spare USB-keyboard, I have a laptop to which I can connect my possibly faulty keyboard to narrow down possibilities :).
This test project runs on the laptop without issues. Both with the integrated keyboard and the keyboard from my desktop PC where I had issues. My laptop runs Windows 11. So I conclude that it is quite possible that the source of the issue should be somewhere in OS configurations. I’ll try to compare keyboard settings on my machines in the meantime.

I cannot reproduce this issue anymore. I spent several days hunting the fix and the issue just disappeared by itself. I’m not sure what was its reason or what fixed it.

The only unusual things I have done today are:

  • detaching and reconnecting my keyboard to the same USB-slot (while I was testing the keyboard on a different machine);
  • waking my desktop PC after it went to sleep on its own.

Thank you everybody for your time and for sharing your experience with me.

USB Keyboard here (Corsair mechanical keyboard)
Project runs fine on my hardware. Holding W, getting a stream o 1 with no 0. Only when w is not pressed I am getting 0’s.

Thank you :slight_smile: really appreciate it.

My GUESS would be a keyboard or connectivity issue of some kind. Maybe not the keyboard itself. Maybe just a hiccup. Replugging the keyboard is my first guess on what may have fixed it.

I know of another kind of input stutter, but the input itself (0 and 1) doesn’t stutter. Instead it stutters because (I think) framerate and input don’t entirely sync up. You’ll still get a steady stream of 0’s and 1’s in that case.