added ability to specify multiple keys that could trigger the event #234

Closed
wants to merge 17 commits into
from

2 participants

@seanmonstar

being able to allow either J or down arrow to trigger a handler using :keys(j|down) individually

Involves defining keys pseudo on Events, and alter Keyboard to use the Events pseudo.

seanmonstar and others added some commits Mar 15, 2011
@seanmonstar seanmonstar added ability to specify multiple keys that could trigger the event
ex. keypress:keys(j,down,enter)
f7a9c69
@seanmonstar seanmonstar using pipe instead 9b767cc
@seanmonstar seanmonstar Event.definePseudo now calls Events.definePseudos, also updating Keyb…
…oard to simply use the full power of the keys pseudo
940e5d9
@seanmonstar seanmonstar Keyboard api says "ctrl" is equal to "control", so added that back in…
…. also, allowing regular keyup and keydown events to pass through, needed by the Events.Pseudos.Keys
1c08be7
@arian arian Add another UI test for :keys with multiple key combinations 6597595
@arian arian Update Docs with multiple combinations for :keys bf2458c
@arian arian Fix whitespace 05e136e
@arian arian :keys now accepts ctrl as well as control. Moved this from Keyboard t…
…o :keys
352f991
@seanmonstar seanmonstar allow the meta (cmd) key to work with :keys pseudo 9190857
@seanmonstar seanmonstar remove modifiers from pressed on the first event that no longer has t…
…hem active
790208d
@seanmonstar seanmonstar removed modifiers, pressed array will clear when a combination is found b63c4ab
@seanmonstar seanmonstar spec description changed to use pipe 230bdc9
@seanmonstar seanmonstar adding meta to Event.Keys 300669a
@seanmonstar seanmonstar cache the parsing of the keys text ed4a7a7
@seanmonstar seanmonstar use a delay, so that other listeners for the same combination still t…
…rigger, but then pressed is emptied afterwards.

fixes tests, since they would trigger the key events all at once, the pressed array would contain all the keys. This would could callback5 to be wrongly called.
ceadeea
@seanmonstar seanmonstar define :keys pseudo on both Event, and Events f820982
@arian
MooTools member

Looks nice! Can't really justify about Keyboard.js, but the other stuff looks good.

One tiny note before pulling this: https://github.com/mootools/mootools-more/pull/234/files#L1R25 should change from ) { to ){

@arian
MooTools member

@anutron got some time to test and pull this?

@seanmonstar

alright. sounds good.

@w00fz w00fz commented on the diff May 23, 2011
Source/Element/Element.Event.Pseudos.Keys.js
-
- if (!this.retrieve(keysKeyupStoreKey)){
- var keyup = function(event){
- (function(){
- pressed = this.retrieve(keysStoreKey, []).erase(event.key);
- this.store(keysStoreKey, pressed);
- }).delay(0, this); // Fix for IE
- };
- this.store(keysKeyupStoreKey, keyup).addEvent('keyup', keyup);
- }
-
-});
+ keysKeyupStoreKey = '$moo:keys-keyup',
+ keysParsed = {},
+ parseKeys = function(text){
+ return text.replace(/ctrl/g, 'control').split('|').map(function(key) {
@w00fz
MooTools member
w00fz added a line comment May 23, 2011

Maybe should clean it up also .replace(/\s/g, '')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@seanmonstar

Either Timmeh's landed, or he didn't like this one anyways.

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