The bug doesn't happen when sneaking or sprinting using a button other than Control or Shift, doesn't happen in single player worlds, is not version specific, and is not server specific.
I tried reinstalling all versions of Minecraft, and I tried deleting .minecraft completely and reinstalling. Both did not fix the problem.
Related issues
Comments


I fail to see how this is a duplicate, as the issue only happens in Minecraft. If you could elaborate, that would be helpful.

It means that this issue has been reported before, and that you are describing the same issue. If it is relevant, help to work around/fix this is described at the bug you duplicated

@unknown, did you read MC-54194 ?

Yes, I did, and if I'm not mistaken, that issue is about how multiple simultaneous key presses don't register. I don't see how it's the same issue. (I hope I'm not coming across as argumentative, I'm legitimately confused)

Could be caused by sticky keys. You might have enabled them by accident

I ended up solving the issue anyways; it was a software issue (which is strange nonetheless as it only happened when online). I have a soundboard program, and I think that the specific way it reads keyboard inputs somehow interfered with how Minecraft reads inputs.
Keyboard controller issue, see MC-54194