web-sys-main-loop as per the name suggests provides a main loop (in game development communities often called a game loop), for web-sys based WASM pages, with also providing input handling.
use web_sys_main_loop::FrameState;
...
let window = web_sys::window().unwrap();
...
web_sys_main_loop::start(&window, move |frame_state: FrameState| {
...
// Gets the position (X, Y) of the cursor in the window
// context
let curr_position = frame_state.mouse_state.get_position();
...
});