gaucho-labs / leptos-hotkeys

a declarative way of using keyboard shortcuts + callbacks in leptos applications
https://leptos-hotkeys.vercel.app
MIT License
45 stars 8 forks source link

README first code example #44

Closed LeoniePhiline closed 6 months ago

LeoniePhiline commented 6 months ago

I might be misunderstanding this, but I believe the logging in the “Global hotkeys” example has a tiny mistake:

use leptos_hotkeys::prelude::*;

#[component]
pub fn SomeComponent() -> impl IntoView {
    let (count, set_count) = create_signal(0);

    // creating a global scope for the W key
    use_hotkeys!(("w") => move |_| {
-        logging::log!("s has been pressed");
+        logging::log!("w has been pressed");
        set_count.update(|c| *c += 1);
    });

    // this is also a global scope for the S key!
    use_hotkeys!(("s", "*") => move |_| {
-        logging::log!("t has been pressed");
+        logging::log!("s has been pressed");
        set_count.update(|c| *c -= 1);
    });

    view! {
        <p>Current count: {count}</p>
    }
}
friendlymatthew commented 6 months ago

Thanks for catching this lol. Feel free to open a PR with this fix! I can gladly do this, but if you want to contribute to the library, I don't want to steal an opportunity.