469,338 Members | 8,242 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,338 developers. It's quick & easy.

how terminate console(not Ctrl-C)

Is it possible to interrupt loop (program) by pressing Q key like Ctrl-
C?
how can i hook user's keypress while program running?

thnx
Nov 22 '07 #1
1 1576
oj
On Nov 22, 3:58 am, NoName <zaz...@gmail.comwrote:
Is it possible to interrupt loop (program) by pressing Q key like Ctrl-
C?
how can i hook user's keypress while program running?

thnx
There's a quite complicated example here:

http://aspn.activestate.com/ASPN/Coo.../Recipe/203830

But it seems to just boil down to fiddling around with tty, and then
using select to read from sys.stdin to detect a keypress, and then
taking the appropriate action.

This will be different on Windows. If you really need this, it might
be worth looking for a library that will make key press detection
trivial. For example, this sort of thing is easy with pygame.
Nov 22 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by abovetreeline | last post: by
4 posts views Thread by Dr. J | last post: by
3 posts views Thread by Keith Grefski | last post: by
3 posts views Thread by Peter Neuburger via .NET 247 | last post: by
7 posts views Thread by fyi85 | last post: by
2 posts views Thread by Draw | last post: by
3 posts views Thread by Laurence | last post: by
1 post views Thread by Justin | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Purva khokhar | last post: by
1 post views Thread by haryvincent176 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.