Skip to content
This repository was archived by the owner on Jul 2, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions include/input_handler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import sys

if sys.platform == "win32":
import msvcrt
getch = msvcrt.getch
else:
import tty, termios
def getch():
fd = sys.stdin.fileno()
old = termios.tcgetattr(fd)
try:
tty.setraw(fd)
return sys.stdin.read(1)
finally:
termios.tcsetattr(fd, termios.TCSADRAIN, old)

print("Start typing (press Enter to finish):")

def input_loop(gameinput_func):
while True:
char = getch()
# if char == 'my super secret escape code':
# do_some_launcher_magic(char)
# else:
gameinput_func(char)
print(f"{char}")