I'm trying to add a button to the overlay that mimics a keyboard key being pressed. for example when I press this button the interface under it does whatever happens when the "e" button is pressed.
all of the topics I've found searching were either very old using `ui.key` or where binding specific actions instead of a general keypress. is there a way to do it?
simulate a keypress from python
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
- Ocelot
- Lemma-Class Veteran
- Posts: 2402
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
- Contact:
Re: simulate a keypress from python
I am not sure if pysdl used by RenPy exposes that, but you can try to use pygame interface for that:
https://www.pygame.org/docs/ref/event.html
Code: Select all
import pygame
key_event = pygame.event.Event(pygame.locals.KEYDOWN, unicode="e", key=pygame.locals.K_e, mod=pygame.locals.KMOD_NONE)
pygame.event.post(key_event)
< < insert Rick Cook quote here > >
Who is online
Users browsing this forum: Google [Bot], Semrush [Bot]