Search code examples
operating-systemuser-inputgame-enginekeystroke

How a program/ video game knows how deep an input is press


I'll jump higher in platform game if i fully press the scape bar . I'll go faster in racing game if i press 'w' down to bottom. How does the game (or the OS) can know that ?

note : this is most notifiable with controller trigger

I always thought keystroke (or gamepad buttons) were binary : pressed or not. Simple.
for e.g : how can i drive faster in GTA V when i fully pressed 'w' on my keyboard or 'RT' on my controller?

How is it programmable? Is it at OS level ?


Solution

  • There are a couple different types of input, you have analog and digital. Digital is the one that you are thinking about; it's binary - on or off. The triggers, joysticks and any motion controls would be analog. They usually have a range that they send.

    Now the space bar and "W" key can't tell how hard you press it. Some games have logic to see how long the key is pressed, and reacts to that.