I am running ML model, which predicts fingure gestures.I am trying to simulate key press event in python using pynput library and I check it's working fine.But I have other program which Is a game written in python using pygame library , which opens up in a new window , but the problem is key press controls doesn't work on that, but it works when I manually press keyboard buttons.
I solved the problem by emulating key press event  using keyboard.press and listen the same event using keyboard.Listner() both are present in keyboard library.So I didn't use pygame functions to listen the event. Thanx everyone for ur help.
How to simulate key press event in python on another program running in python