0

I do not have code to show this but I do have code that makes you have to type 'a' to start and was wondering if there was a way to make them not have to press enter and just be able to press that key for it to start without using pygame. If you do have to use pygame then please inform me how. Thank you and make any edits to this code if you can to try and do what I asked. :D

while (True):
    print("-----------------------------------------------------------")
    print("\033[1;37;40m ")
    name = input("Type your name: ")
    srt=input("Type 'a' to start! ")
    if srt == 'a':
        break
Fiix
  • 27
  • 1
  • 3

1 Answers1

0

To do this, I believe you need the msvcrt package, especially since you are using windows. While I am not experienced with msvrct, you will need aomething like

msvrct.getch()

I'm not completely sure. But a way I would do this is using pygame, which is more easier to understand. You could do:

from pygame import key
from pygame.locals import *
pygame.init()
while True:
   pressed = pygame.key.get_pressed()
   if pressed[K_a]: 
       break

For more information, you can look at the pygame module index. Tell me if these solutions work.

Ethanol
  • 370
  • 6
  • 18