Making python quit program instantly when hitting ESC
问题 I'm making an algorithm that reads input from keyboard, stores it on a variable called message and then write this variable into a file. However, whenever the user is typing, if he hits the ESC key, I'd like the execution to stop without any errors. Let's say the code is: message = raw_input() What do I have to add? So if I'm in the middle of a sentence like: My name is th And I hit ESC, it stops? 回答1: There is no way to do this with normal input. raw_input reads a whole line at a time. In