I tried this but doesn't work in my case, I want to convert it in a function that prints slow but if I hit enter just completes the whole sentence. I tried this but doesn't work.
import time
import sys
from threading import Thread
def controlled_print(str):
# Function to skip slow printing
waiting_time = 0.08
def check():
i = input()
global waiting_time
waiting_time = 0
Thread(target = check).start()
# Function to do slow print
def print_slow(str):
for letter in str:
sys.stdout.write(letter)
sys.stdout.flush()
time.sleep(waiting_time)
print_slow(str)
controlled_print('This sentence should print instantly if I hit "Enter".')