2

Is there a way to take the users input without them having to press enter? I searched this question but most of the answers are for Python 2 or don't work.

I don't understand or this solution doesn't work: How to accept input without the need to press enter Python 3

Regi
  • 31
  • 1
  • 6
  • OS === Windows. – Regi Dec 15 '17 at 19:11
  • Possible duplicate of [How to accept input without the need to press enter Python 3](https://stackoverflow.com/questions/20831773/how-to-accept-input-without-the-need-to-press-enter-python-3) – fredtantini Dec 15 '17 at 19:13
  • 1
    Possible duplicate of [raw\_input in python without pressing enter](https://stackoverflow.com/questions/3523174/raw-input-in-python-without-pressing-enter) – kabanus Dec 15 '17 at 19:16
  • Are you using a console window or a GUI / IDE? – Eryk Sun Dec 16 '17 at 01:18
  • there is a keyboard third-party module you can install that has some things like this, if that is what you want. – Michael Dec 16 '17 at 04:25
  • I asked whether it's a console or GUI application because answers to previous questions have focused exclusively on using the Windows console, which doesn't address using alternative console's such as IDLE's PyShell or QtConsole. In these cases a GUI framework is used to create a console window, which is totally unrelated to the Windows console API. – Eryk Sun Dec 16 '17 at 21:15
  • I would like to make a pong game for 2 people on tkinter. It would be nice if it worked on a terminal – Regi Dec 17 '17 at 11:14

1 Answers1

1

You can use msvcrt on windows to allow the user to enter one value, then enter it without needing to actually pres the enter key.

import msvcrt                    #You will need this.
your_variable = msvcrt.getch()   #Allows the user to enter a single value, 
                                 #then immediately enter it.

Side note: You cannot run this properly in the shell, just run it straight from your folder. Also, in case you're feeling lazy, you can use my module that I created here, if you use it and notice any errors, please let me know as it would help me get better at python. I hope I helped you!