Wait for user to press key before printing text

Is there a way to make it to where if you press ANY key it will go to the next text?
i dont want all the text to be blobbed together because its messy!

You can use fkeycapture to achieve this. If you provided some code or the link to your Repl we could give more specifics.

1 Like
print("Its a new day! time for you to go to school!")
#(here is where i want to any key to be)

You can use getkey

from getkey import getkey


how do i even use getkey? can you give me an example?

Like they always say, Google is the programmer’s best friend :slight_smile:. Try looking at the module’s documentation. (getkey · PyPI)

you can also use @Firepup650’s fkeycapture · PyPI (probably better)

Hope this helped, and if you have any more questions feel free to ping me :D

1 Like

…I already showed you how to use it.


where would i put the Import thingy? would i put it on main.py, or like a different thing?

At the top of main.py.

1 Like

Thank you! thats what ive been trying to ask!

wait why is this showing?

from getkey import getkey
Traceback (most recent call last):
  File "/home/runner/DDLC-The-perfect-world/VM3.py", line 1, in <module>
    from getkey import getkey
ModuleNotFoundError: No module named 'getkey'
exit status 1

You need to run pip install getkey. If that fails try poetry add getkey.

Type upm add getkey in the Console

how do i “pip install getkey?”

heres the link,

You have to go to the Shell, and type out that command.

This also works, I made it pretty quickly:

import sys

class TerminalInput:
    def __init__(self):
        self.input_buffer = []

    def read_line(self):
            # Read a line of input and append it to the buffer
            line = sys.stdin.readline().strip()
        except KeyboardInterrupt:
            print("\nInput interrupted. Exiting...")

    def process_input(self):
        while True:
            last_line = self.input_buffer[-1]
            if last_line.lower() == 'quit':

            print(f"Output: {last_line}")

    def run(self):
        print("'quit' to exit.")

if __name__ == "__main__":
    terminal = TerminalInput()

1 Like

I had a stroke trying to read this lol

Anyways i still dongt understand how to do this,
What im trying to do is make it to where when i press any key on my keyboard to shows the next printed text

It’s a rewrite of Python’s built-in input() function. I created it because input() arbitrarily stops all processes, which can be annoying. This doesn’t do that, and I didn’t feel like using an external package or library for handling key events, terminal input, etc.