After each 0 is typed, I want it so it'll press enter afterward, I've tried different lines but it didn't, I'm a complete beginner, pls help.
from pynput.keyboard import Key, Controller
import time
keyboard = Controller()
time.sleep(1)
for char in " 0 0 0 0 0 0 0":
keyboard.press('0')
keyboard.release('0')
time.sleep(0.25)
Pressing an enter
with pynput
is similar to what you have done, see here from the docs. You would want to do something like the following.
word = " 0 0 0 0 0 0 0"
for i, char in enumerate(word):
if char == "0":
keyboard.press('0')
keyboard.release('0')
#last iteration
if char == "0" and len(word)-1 == i:
keyboard.press(Key.enter)
keyboard.release(Key.enter)
break #break the loop here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With