0

I want to stop an input. Where the user inputs a string of a certain length then python "presses enter for them," and cuts the input short.

print("[Play]  Cheats  Credits  ", end='')
inp=input("")
if inp=="d":
    print("Play  [Cheats]  Credits  ", end='')
    inp=input("")
if inp=="a":
    ...

I would like it to take the input instantly after the user inputs a single letter. Thanks.

jonrsharpe
  • 107,083
  • 22
  • 201
  • 376
diligar
  • 393
  • 3
  • 11

1 Answers1

0

This is a nonblocking raw-input. It's implementation differs from OS to OS. The this post for a starting point: http://repolinux.wordpress.com/2012/10/09/non-blocking-read-from-stdin-in-python/#select

dorvak
  • 8,363
  • 4
  • 32
  • 42