Im Trying to Detect a Certain Key being Pressed (Python) -
this code, im beginner , ive been looking around ive looked @ atleast 5-10 posts this, aren't helping me because cant understand code.
in code im trying basic starting screen game , want how detect e or s being pressed @ time of start screen,
print (" _____________________________________________ ") print ("| |") print ("| |") print ("| chronicles |") print ("| of game |") print ("| |") print ("| |") print ("| |") print ("| |") print ("|_____________________________________________|") print ("| |") print ("| start exit |") print ("| (s) (e) |") print (" \___________________________________________/ ")
i use getch, if want use, download py-getch:
https://github.com/joeyespo/py-getch
the command install: python setup.py install
example code:
from getch import getch, pause # game loop while(true): key = getch() if(key == 's'): print('key s pressed...') elif(key == 'e'): print('key e pressed...')
Comments
Post a Comment