Skip to content

Commit 37748c8

Browse files
koenvanwijkpre-commit-ci[bot]aliberts
authored
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 <[email protected]>
1 parent 3fb04ef commit 37748c8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lerobot/common/utils/utils.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,15 @@ def is_valid_numpy_dtype_string(dtype_str: str) -> bool:
233233

234234

235235
def enter_pressed() -> bool:
236-
return select.select([sys.stdin], [], [], 0)[0] and sys.stdin.readline().strip() == ""
236+
if platform.system() == "Windows":
237+
import msvcrt
238+
239+
if msvcrt.kbhit():
240+
key = msvcrt.getch()
241+
return key in (b"\r", b"\n") # enter key
242+
return False
243+
else:
244+
return select.select([sys.stdin], [], [], 0)[0] and sys.stdin.readline().strip() == ""
237245

238246

239247
def move_cursor_up(lines):

0 commit comments

Comments
 (0)