Pressing Enter to skip print?
<p>I'm making a sort of text based game in python and I was wondering if there was a way to skip print's while playing by just pressing enter. </p>

<p>Let's say I have this code.</p>

<pre><code>    print("BORING")
    time.sleep(5)
    print("ANNOYED")
    time.sleep(5)
</code></pre>

<p>and I just want to skip the wait by pressing the Enter key.
The main reason I'm asking is because I use</p>

<pre><code>def print_slow(str):
for letter in str:
    stdout.write(letter)
    stdout.flush()
    time.sleep(0.1)
</code></pre>

<p>a lot to have the prints type the text, but I want players to be able to skip to the next line of code by pressing Enter. Or a really cool feature if anyone can help me is when I press enter it speeds up the text. I know python isn't the best for creating games but I felt it would be a fun challenge to just attempt a text based game with normal functions.</p>

<p>Thanks!</p>

<p>For speeding up your text, you could map the text to a function that prints it all (or iterates through it and prints one letter/word at a time... depending on what it is you're trying to accomplish). This function could be called on keypress using the tkinter library:</p>

<pre><code>import tkinter

def speed_up(event=None): 
    print('Speeding up!') 

main = Tk() 

opt = Button(main, text = 'Press Enter', command = speed_up)
opt.pack()

main.bind('&lt;Enter&gt;', speed_up)
</code></pre>

<p>This could also be used to skip text.</p>

python