whenipress icon indicating copy to clipboard operation
whenipress copied to clipboard

Sequential key support

Open lukeraymonddowning opened this issue 4 years ago • 11 comments

I've been thinking about adding sequential key support to whenipress.

The idea is that instead of registering a keyboard combo, you register a set of key presses that must be pressed in order. The syntax would look something like this:

whenipress('a', 'b', 'c', 'd', 'e', 'f', 'g').sequentially().then(e => alert('You know the start of the alphabet!'));

My issue is I don't know how widely used this would be, and I don't want to bloat the package with unused features as I'd like it to remain as small as possible. I did think of releasing it as a plugin that works alongside whenipress. Any thoughts or ideas are appreciated.

lukeraymonddowning avatar Jul 03 '20 07:07 lukeraymonddowning

I would propose to make the syntax more group like - so it would be: whenipress().sequence('a', 'b', 'c').then(e => alert('First three letters of the alphabet pressed sequentially'));

But from my experience I never saw a use-case for this. 🤷

jreitz-dev avatar Jul 07 '20 10:07 jreitz-dev

It would be handy for the Konami Code :-)

millette avatar Jul 11 '20 03:07 millette

@millette But how many times did you implement the Konami Code onto a website ? I sadly never had the chance to.

jreitz-dev avatar Jul 14 '20 07:07 jreitz-dev

@jkonze Once, that I remember. It was for a special feature I was ready to announce publicly, but it had great effect when I gave a presentation and launched (manually) the feature :-) True story!

millette avatar Jul 14 '20 09:07 millette

The more I think about this, the more I think it would fit 'plugin' territory better

lukeraymonddowning avatar Jul 14 '20 15:07 lukeraymonddowning

Another use-case for sequences is something like gmail and it's support for "g i" meaning "Go to Inbox". It supports other sequences, that's just the first that comes to mind.

P.S.: I'm not insisting for the feature, just laying out a few usage examples.

millette avatar Jul 14 '20 15:07 millette

I've played around with the plugin way of implementing it. Shouldn't be too difficult - though I wasn't able to make it work 💯% of the time due to issues with 2nd layer characters ( / on my keyboard for example).

jreitz-dev avatar Jul 14 '20 18:07 jreitz-dev

This would be a great feature. It is the one lacking feature that prevented me from using it.

TfTHacker avatar Aug 26 '20 07:08 TfTHacker

It's not the most beautiful thing to do, but by nesting whenipress you can create sequences.

DionPotkamp avatar Apr 02 '21 12:04 DionPotkamp

@DionPotkamp would you have a code example to show what you mean?

lukeraymonddowning avatar Apr 02 '21 15:04 lukeraymonddowning

Sure! It's acting weird if you don't add the .once()'s. The first whenipress shouldn't have the .once().

whenipress('a').then(e =>  
    whenipress('d').then(e =>  
        whenipress('m').then(e =>  
            whenipress('i').then(e =>  
                whenipress('n').then(e =>  
                    console.log("admin!")  
                ).once()  
            ).once()  
        ).once()  
    ).once()  
)  

DionPotkamp avatar Apr 02 '21 15:04 DionPotkamp