Re: stopping a while True: with the keyboard
- From: Ben Finney <bignose+hates-spam@xxxxxxxxxxxxxxx>
- Date: Wed, 26 Sep 2007 13:20:18 +1000
Benjamin <musiccomposition@xxxxxxxxx> writes:
On Sep 25, 8:19 pm, patrick <pured...@xxxxxxxxx> wrote:
hi all,
i am looking for a way to break a while True: when pressing "s" on my
keyboard. how can i do this?
pat
Ctrl-C
That's not a very helpful response, since it doesn't address the OP's
request.
Patrick, the operating system "interrupt current process" keyboard
signal will cause Python to raise a 'KeyboardInterrupt' exception,
which unless caught will propagate back to the top-level Python
process and exit the program with a traceback.
On most operating systems, you can send this signal to the current
foreground process with the key combination Ctrl+C. I think that's
what Benjamin's laconic response is implying.
As for "detect a specific keypress", there's no OS-independent way to
do that. You'll need to write code that depends on a particular way of
getting at keypresses that won't work on all operating systems.
--
\ "Those who write software only for pay should go hurt some |
`\ other field." -- Erik Naggum, in _gnu.misc.discuss_ |
_o__) |
Ben Finney
.
- References:
- stopping a while True: with the keyboard
- From: patrick
- Re: stopping a while True: with the keyboard
- From: Benjamin
- stopping a while True: with the keyboard
- Prev by Date: Re: the address of list.append and list.append.__doc__
- Next by Date: Re: An Editor that Skips to the End of a Def
- Previous by thread: Re: stopping a while True: with the keyboard
- Next by thread: Re: stopping a while True: with the keyboard
- Index(es):
Relevant Pages
|