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
  • 115,751
  • 26
  • 228
  • 437
diligar
  • 413
  • 5
  • 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
  • 9,219
  • 4
  • 34
  • 43