Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Raw Text Input

Sometimes there’s a need to catch all text input events. This can be done by listening to WindowEvent::KeyboardInput like so:

#![allow(unused)]
fn main() {
#[derive(Visit, Clone, Reflect, Debug)]
struct MyPlugin;

impl Plugin for MyPlugin {
    fn on_os_event(&mut self, event: &Event<()>, context: PluginContext) -> GameResult {
        if let Event::WindowEvent { event, .. } = event {
            if let WindowEvent::KeyboardInput { event, .. } = event {
                if let Some(text) = event.text {
                    println!("{}", text);
                }
            }
        }
        Ok(())
    }
}
}