Event handling
This module provides comprehensive event handling for keyboard input, including escape sequences and arrow keys for POSIX systems.
Types
Event = object case kind*: EventKind of Key: key*: KeyEvent of Mouse: mouse*: MouseEvent of Paste: pastedText*: string of Resize, FocusIn, FocusOut, Quit, Unknown: nil
EventKind = enum Key, Mouse, Resize, Paste, FocusIn, FocusOut, Quit, Unknown
MouseEvent = object kind*: MouseEventKind button*: MouseButton x*: int y*: int modifiers*: set[KeyModifier]
Procs
proc `$`(event: Event): string {....raises: [], tags: [], forbids: [].}
- String representation of an Event for debugging
proc `$`(key: KeyEvent): string {....raises: [], tags: [], forbids: [].}
- String representation of a KeyEvent for debugging
proc `$`(mouse: MouseEvent): string {....raises: [], tags: [], forbids: [].}
- String representation of a MouseEvent for debugging
proc hasInput(): bool {....raises: [], tags: [], forbids: [].}
- Check if input is available without blocking
proc pollEvents(timeoutMs: int): bool {....raises: [], tags: [], forbids: [].}
- Poll for available events with a timeout Returns true if events are available, false if timeout occurred Similar to crossterm::event::poll()
proc readKeyInput(): Option[Event] {....raises: [], tags: [], forbids: [].}
- Read a single key input event (non-blocking) Returns none(Event) if no input is available or on error
proc waitForAnyKey(): bool {....raises: [Exception], tags: [RootEffect, ReadIOEffect, TimeEffect], forbids: [].}
- Wait for any key press, return true if not quit
proc waitForKey(): Event {....raises: [Exception], tags: [RootEffect, ReadIOEffect, TimeEffect], forbids: [].}
- Wait for a key press (blocking)