Start a new thread to get key input. Access the string variable key by renderer.key. Bool variable pause can also be accessed by renderer.key. Press Shift + P to set it opposite. Quit by pressing Shift + Q (With it starting, you can no longer end the program by Ctrl + C.) After quitting
()
| 427 | |
| 428 | |
| 429 | def keyinput() -> None: |
| 430 | """Start a new thread to get key input. Access the string variable key by renderer.key. |
| 431 | Bool variable pause can also be accessed by renderer.key. Press Shift + P to set it opposite. |
| 432 | Quit by pressing Shift + Q (With it starting, you can no longer end the program by Ctrl + C.) |
| 433 | After quitting, renderer.key would remain "Q" |
| 434 | I don't really recommend you to use it and, rather, you'd better do it yourself.""" |
| 435 | def key_capture(): |
| 436 | global key, pause |
| 437 | from msvcrt import getwch |
| 438 | while True: |
| 439 | key = getwch() |
| 440 | if key == "P": |
| 441 | pause = not pause |
| 442 | key = None |
| 443 | elif key == "Q": |
| 444 | break |
| 445 | from threading import Thread |
| 446 | global key, pause |
| 447 | globals()["key"], globals()["pause"] = None, False |
| 448 | Thread(target=key_capture, daemon=True).start() |
| 449 | |
| 450 | |
| 451 |
nothing calls this directly
no outgoing calls
no test coverage detected