SDL: Checking how hard a key was pressed?

Is there a way to check how hard a key was pressed?

For example if you want a player to be able to jump certain heights depending on how hard you pressed the button.


NVM Solved it, Im so stupid.

I actually set the Y speed to something low if the jump key was released, so the player starts to drop.
Last edited on
It doesn't matter how hard you press a key, but the length of time you hold it down can be significant.

When the key is pressed, make a note of the time. Then while the character is jumping, take note of whether the key is still pressed at the important junctures.

If you are unsure about how this works, get yourself a Neo-Geo emulator and a copy of World Heroes and see how it works. ;-)

There is no way for the computer to determine that. You would need a specially designed device for that.

I guess the easiest thing might be to test for the amount of time the key is down, or multiple key presses in quick succession, to determine jump height.

I don't know anything about SDL, but there are plenty of others who do.

Topic archived. No new replies allowed.