I have an application and I want whenever the user presses RETURN/ENTER it goes to a def with an input.
I am using this code:
while True:
z = getch()
# escape key to exit
if ord(z) == 9:
self.command()
break
if ord(z) == 27:
print "Encerrando processo.."
time.sleep(2)
sys.exit()
break
But it just blocks there and If I have more code it won't run it, only if the while is broken. I can't use tkinter either!
Is there anything that only runs if the key is pressed? Without looping.