Breaking out of a while loop with a key press?

Richard richardd at hmgcc.gov.uk
Mon Mar 31 10:12:20 EST 2003


Hi,

Can anyone suggest a simple way of detecting a key press and existing the
program? I have a program which at the moment uses a while True: statement.
However this is not ideal as I have to close down the console window to
exist the program. Can anyone tell me the proper way of doing this? So that
a CTRL-C, for example, can quit the program correctly?

Cheers

Richard






More information about the Python-list mailing list