-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Summary
Add keyboard input capability to naml runtime to enable interactive programs.
Proposed API
// Blocking read - waits for user input
fn read_line() -> string;
// Non-blocking key read (for games) - returns key code or -1 if no key pressed
fn read_key() -> int;
Use Cases
- Interactive CLI applications
- Games (snake, tetris, etc.)
- User prompts and menus
Implementation Notes
read_line()- blocking, reads until newlineread_key()- non-blocking, requires terminal raw mode- Platform considerations:
- Native: use
std::io::stdin()with raw mode viatermios - Server WASM: WASI stdin
- Browser: Not applicable (use DOM events instead)
- Native: use
Acceptance Criteria
-
read_line()reads a line of text from stdin -
read_key()returns key code without blocking - Arrow keys return distinct codes
- Works on native platform
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels