gaucho-labs/leptos-hotkeys

Spacebar key not working

boyswan opened this issue · 1 comments

With event: web_sys::KeyboardEvent, event.key() is " " for space which does not work.

I have tried both string and char:

  use_hotkeys!((" ", ' ') => move |_| {
    leptos::logging::log!("hit");
  });

Perhaps the ability to configure using event.key vs event.code is needed for this, as in this case event.code() == "Spacebar"

Thanks @boyswan, I've decided to use code https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code as our key identifier. A note, it is good to have the debug feature flag turned on, this way you can see the pressed key codes in your browser console :)

I've had thoughts about strongly typing these keys, but due to all the variance, I felt the authors left it as a String intentionally. What do you think?