From 37748c83ca70561e6fab9cb5669fb47b055e911b Mon Sep 17 00:00:00 2001 From: koenvanwijk Date: Tue, 10 Jun 2025 18:36:02 +0200 Subject: [PATCH] Proposal for fix for enter_pressed on Windows (#1230) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Simon Alibert <75076266+aliberts@users.noreply.github.com> --- lerobot/common/utils/utils.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lerobot/common/utils/utils.py b/lerobot/common/utils/utils.py index 756ad9f0..08e9a3c0 100644 --- a/lerobot/common/utils/utils.py +++ b/lerobot/common/utils/utils.py @@ -233,7 +233,15 @@ def is_valid_numpy_dtype_string(dtype_str: str) -> bool: def enter_pressed() -> bool: - return select.select([sys.stdin], [], [], 0)[0] and sys.stdin.readline().strip() == "" + if platform.system() == "Windows": + import msvcrt + + if msvcrt.kbhit(): + key = msvcrt.getch() + return key in (b"\r", b"\n") # enter key + return False + else: + return select.select([sys.stdin], [], [], 0)[0] and sys.stdin.readline().strip() == "" def move_cursor_up(lines):