Skip to main content

poll_input

Function poll_input 

Source
pub fn poll_input(timeout: Duration) -> Result<InputEvent>
Expand description

Poll for input events with timeout

Returns InputEvent::Other if timeout expires without input. Only processes key press events (ignores key repeat/release).

§Arguments

  • timeout - Maximum time to wait for input

§Example

use issun::ui::input::poll_input;
use std::time::Duration;

loop {
    let event = poll_input(Duration::from_millis(100))?;
    match event {
        InputEvent::Quit => break,
        InputEvent::Up => player.move_up(),
        InputEvent::Other => { /* timeout, continue game loop */ }
        _ => {}
    }
}