pub fn use_event_with_window<T, F, E>(event_type: T, callback: F) where
    T: Into<Cow<'static, str>>,
    F: Fn(E) + 'static,
    E: From<JsValue>, 
Expand description

A hook that subscribes a callback to events only for window. If you want to specify an event target, use use_event.

Example

use yew_hooks::use_event_with_window;

#[function_component(UseEvent)]
fn event() -> Html {
    use_event_with_window("keypress", move |e: KeyboardEvent| {
        debug!("{} is pressed!", e.key());
    });
     
    html! {
        <>
            { "Press any key on your awesome keyboard!" }
        </>
    }
}