gaucho-labs / leptos-hotkeys

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

Support "sticky keys" #2

Open gihrig opened 9 months ago

gihrig commented 9 months ago

Sticky Keys is a feature in macOS that allows users with limited dexterity to use keyboard shortcuts in sequence instead of holding them down at the same time.

This works by implementing a delay after a key press in which the next key press is added in sequence to the delayed key.

For example, to copy highlighted text you normally press a multi-key sequence Ctrl-C.

This feature would allow the same operation by pressing and releasing Ctrl then pressing C within the delay period.

The delay period should be programmable and assignable. That is, applicable only to selected keys rather than to all keys vs none.

While this is considered an accessibility feature, my intended use case is to bring a hidden note taking app to the foreground by rapidly pressing a key twice (or more times) in succession.

friendlymatthew commented 9 months ago

Thanks @gihrig!

This seems like a cool use case, and something that can be introduced as an optional feature.

Something like:

use_hotkeys(
    "ctrl+v",
    Callback::new(move |_| {
        set_count.update(|count| {
            *count += 1;
        });
    }),
   option::Sticky(
       30, // some time threshold
   )
);

So we'll listen for ctrl and v within the 30ms cooldown period.

Full transparency: I'm quite limited with time right now since I have to focus on work. If you want to give this a go, that would be super awesome

gihrig commented 9 months ago

@friendlymatthew Similar situation with work ATM. When I get to the point where this is a blocking feature, I'll have time to devote. Not sure just when that will be though.

In the mean time it's been recorded for a future todo.

friendlymatthew commented 9 months ago

In the mean time it's been recorded for a future todo.

Awesome. I'll tentatively assign this to you. No sweat and definitely no pressure.

Best of luck with work!

PS. Feel free to suggest more ideas, really appreciate your insight 🤠

friendlymatthew commented 9 months ago

Hey @gihrig any update to this? Just checking in 😄. All good if you're too busy!

gihrig commented 9 months ago

@friendlymatthew Unfortunately the backlog continues to grow... ☹️ At this point the future of the app requiring this feature is in question, so I can't provide a time estimate as to when, or if, I'll get to this. Not entirely forgotten though.

friendlymatthew commented 9 months ago

@gihrig No worries. Best of luck with your work!

friendlymatthew commented 8 months ago

@gihrig -- Just wanted to let you know that I haven't forgotten this issue. After some investigation, it turns out this is a pretty important feature we're lacking. :)

Thanks for raising this issue