i want a getch/cin like function in python that wont interrupt the program from running (wanna make flappyBird) return pressed key ascii code if anything pressed or returns nothing or a default value if no key pressed
i am using getch but it waits till a key press
while (1):
speed = speed - gravity
pressed_key = getch.getch()
if ( pressed_key == ' ' ):
speed = speed + force
pressed_key = 'x'
elif ( pressed_key == 'q' ):
sys.exit()
print (speed)
sleep(sleep_time)
this will be later a frame of the game xD