How can I force a keypress

Like the title say, how can I force a keypress?
I don’t know if this is possible and I want to know if it is and how it can be done

1 Like

You can’t really “simulate” it directly however you can always just call the function that is bound to a key.

3 Likes

you could make a gui that does not disappear until the player presses the key that way the player will be forced to press the key

I think your maybe looking at it all wrong?

You can’t really force a key press, seeming as a key press is done by a user - as such its their choice if they press the key.

What you can do however is:

  • Act like they have pressed it, without pressing it. This is simply done by calling the function / action itself.
  • Put them in a scenario where pressing that key is the easiest way out. Lets use Pokémon as an example:

You can choose to use a leaf type move against a fire type pokémon (this would be ineffective in the game and do little to no damage) OR you can make the user push towards the water type move (which is super effective). Whereas the user could continue by using the less effective move, they would be more drawn psychologically to use the water move seeming as the end goal is the same in both outcomes.

As you can see in that scenario, they are semi forced to press the key through pressure / fear of losing something. Alternatively, you can give them a no win scenario if they don’t press that specific key.

3 Likes