MCPcopy Create free account
hub / github.com/ICE27182/Python-3D-renderer / keyinput

Function keyinput

v1.0/renderer.py:429–448  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

427
428
429def 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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected