Python Forum

Full Version: Pynput while not using text field
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

So Pynput works great when you want to type characters, strings etc, it's great.
However, for a reason I cannot understand, when you want to use the feature of pynput elsewhere, it doesn't seems to work.
An example, if you're in a video game, and you want to crouch with the "C" key, it won't make you crouch, but if you're using the chat system of the online game, it will write "C"s.
There's also some flash games online when you just have to press the spacebar as fast as possible, and it doesn't work. (or only one space is recorded sometimes).
I tried to look up the documentation but I couldn't find anything about it.

Here's the piece of code I wrote:
from pynput.keyboard import Key, Controller
import time
import keyboard as key

keyboard = Controller()

time.sleep(2)
for i in range(30):
    #keyboard.press(Key.space)
    #keyboard.release(Key.space)
    keyboard.press("c")
    keyboard.release('c') 
    time.sleep(0.1)
I tried playing with the time.sleep value but it doesn't change anything.
Could anyone help me try to figure out why it doesn't work ? And how could I fix this issue ?
Thank you !
There are instructions on leaving a message to the author of github page here: https://stackoverflow.com/questions/1268...b-com-user
in your case, author's repository is: https://github.com/moses-palmer/pynput
Hello.

Thanks for the tip i'll try contacting with the author !