Python don't do anything until keystroke -
so need python program or module executes main program once specific key pressed, example f10 key. other modules found (for example getch) executes once any key pressed.
since mention msvcrt
, i'll assume (windows). you'd different in linux.
f10
2-byte return, 00 68
, so... first byte 00
, second byte 68
. there 2-byte return has 224
first byte, you'll want check that, too.
i included block on kbhit()
because if let block on getch()
instead, pick ctrl-c
, won't able break out. blocking on gives opportunity.
you can make little more generic if you'd like, hardcoded f10
.
import msvcrt while true: if msvcrt.kbhit(): first = ord(msvcrt.getch()) if first in (0, 224): second = ord(msvcrt.getch()) if first == 0 , second == 68: break
Comments
Post a Comment