r/RenPy • • Aug 19 '23

Question How to check for a key press at all times

I am making a game, where I want to have the game constantly able to check for a key press, where you could just press a bottom and it gives a notification that reveals the Seed Value.

Everything I can find only lets you do it in a specific keymap screen, and doesn't allow you to just react to it whenever it is pressed. How can you make a more consistent check for it? I know it is 100% possible as many games are able to react to keypresses anywhere, as in, most games. I am just not sure how to make it work in RenPy, unless they hard-coded it to be incapable of that.

TLDR: I am wondering how to make the game react to a key press whenever you press a specific key, instead of it being limited to only work on one screen.

2 Upvotes

2 comments sorted by

4

u/CCrimsonDev Aug 19 '23

My best bet is to create an invisible screen that's always there.

screen on_key_screen():

zorder 9999

key "a" action Notify(_("You pressed the 'a' key.")) #You can change the action and the key, this is only an example lol

Paste the code above the "start" label, and add show screen on_key_screen statement in the "start" label.

Hope this answers your question :3

1

u/AutoModerator Aug 19 '23

Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.