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...') 

key pressed


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -