Skip to content
This repository was archived by the owner on Nov 8, 2017. It is now read-only.

sends key history to triggered function#68

Open
2x2xplz wants to merge 1 commit intokeithamus:masterfrom
2x2xplz:with-history-0.1
Open

sends key history to triggered function#68
2x2xplz wants to merge 1 commit intokeithamus:masterfrom
2x2xplz:with-history-0.1

Conversation

@2x2xplz
Copy link
Copy Markdown

@2x2xplz 2x2xplz commented Jun 17, 2016

Tracks key press history and adds a keySequence object to the final event (which is already sent to triggered function). Useful when using multiple-choice or regex-like syntax. i.e. get the actual 3-digit code that triggered shift+;,[0-9],[0-9],[0-9]. keySequence is an object that contains an object per key press, and also a string representation called sequence using pipes to separate keys: shift+h|e|l|l|o|space|ctrl+w|o|r|l|d

example usage:

jwerty.key('ctrl+shift+;,[a-e],[f-j],[k-o]' , function() { 
  alert(this.event.keySequence.sequence); 
});

jwerty has tremendous potential because of regex support, which other libraries do not have. However its overall support for sequences is spotty, for example, (on Chrome 51/Windows at least) sequences which end in a modifier like a,b,shift+c do not trigger. Some regex edge cases are also unsupported: [a-z],[a-z],[a-z],enter will not be triggered by abcd-enter (I would expect bcd-enter to be the match). Still, the support it does have is great and along with ajax requests, allows for simple password-type sequences that can't be revealed with View Source. I really hope you'll revisit this library and finish 0.4. Thanks.

Tracks key press history and adds a 'keySequence' object to the final 'event' (which is already sent to triggered function). Useful when using multiple-choice or regex-like syntax. i.e. get the actual 3-digit code that triggered 'shift+;,[0-9],[0-9],[0-9]'. keySequence is an object that contains an object per key press, and also a string representation called 'sequence' using pipes to separate keys: shift+h|e|l|l|o|space|ctrl+w|o|r|l|d

example usage: jwerty.key('ctrl+shift+;,[a-e],[f-j],[k-o]' , function() { alert(this.event.keySequence.sequence); });
@wadestuart
Copy link
Copy Markdown

+1 for this type of functionality -- I also have had to fork out to create something similar but some core support for exposing the captures that exercised the event just makes sense given the regex functionality.

Not sure I think the stringified result in this patch is the best option but given a choice between this or nothing this is better. =)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants