pub struct Input;Expand description
A zero-sized namespace struct providing static input event extraction methods.
This struct follows the same pattern as App, serving as a namespace for
free-standing input utility functions that extract data from DOM events.
Implementations§
Source§impl Input
Implements static event extraction methods on the Input namespace struct.
impl Input
Implements static event extraction methods on the Input namespace struct.
Sourcepub fn extract_key_code(event: &Event) -> String
pub fn extract_key_code(event: &Event) -> String
Source§impl Input
Implements DOM event listener registration on the Input namespace struct.
impl Input
Implements DOM event listener registration on the Input namespace struct.
This is the wiring layer that routes DOM events into InputState:
keyboard events bind to window (a <canvas> is not focusable by
default), while mouse and touch events bind to the canvas element so
hit-testing coordinates stay canvas-local. Registered closures are
.forget()-ed and stay alive for the lifetime of the document,
matching the engine’s mount-only convention.
Sourcepub fn attach(
state_cell: InputStateCell,
window: &Window,
pointer_target: &EventTarget,
) -> InputStateCell
pub fn attach( state_cell: InputStateCell, window: &Window, pointer_target: &EventTarget, ) -> InputStateCell
Attaches all input listeners and returns the shared state cell.
§Arguments
InputStateCell- The shared input state to mutate from event handlers.&Window- The global window, receiving keyboard events.&EventTarget- The pointer target (typically the canvas element).
§Returns
InputStateCell- The same cell passed in, for convenient chaining.
Sourcepub fn attach_keyboard(state_cell: &InputStateCell, window: &Window)
pub fn attach_keyboard(state_cell: &InputStateCell, window: &Window)
Binds keydown / keyup listeners to window.
Keyboard events must bind to window rather than the canvas: a
<canvas> element is not focusable unless tabindex is set and the
user clicks it, so canvas-bound key listeners would never fire.
§Arguments
&InputStateCell- The shared input state.&Window- The global window.
Sourcepub fn attach_pointer(state_cell: &InputStateCell, target: &EventTarget)
pub fn attach_pointer(state_cell: &InputStateCell, target: &EventTarget)
Binds mouse / touch / context-menu listeners to the pointer target.
touchstart and touchmove call prevent_default() so the browser
does not interpret touches as scroll/zoom gestures before the engine
sees them. contextmenu is suppressed so right-click reaches the
engine as MouseButton::Right instead of opening the browser menu.
§Arguments
&InputStateCell- The shared input state.&EventTarget- The pointer target (typically the canvas element).