use crossterm::event::{self, Event};
use std::time::Duration;

/// Poll for terminal events.
pub fn poll_event(timeout: Duration) -> std::io::Result<Option<Event>> {
    if event::poll(timeout)? {
        Ok(Some(event::read()?))
    } else {
        Ok(None)
    }
}
