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>You'll need to handle this asynchronously, because you want to be handling two things at the same time. You want to both listen to some kind of input and print out something. </p>

<p>Create an asynchronous task -> let it prent</p>

<p>AND at the same time listen for input() (or another way of registering keypresses). </p>

<p>If input is evoked, cancel the asynchronous task and let player continue in the game.</p>

python