key.js revision 537e74c4e869b8efba925d0e37c0a5636203a23b
/**
* Add a key listener. The listener will only be notified if the
* keystroke detected meets the supplied specification. The
* spec consists of the key event type, followed by a colon,
* followed by zero or more comma separated key codes, followed
* by zero or more modifiers delimited by a plus sign. Ex:
* press:12,65+shift+ctrl
* @event key
* @for YUI
* @param type {string} 'key'
* @param fn {function} the function to execute
* @param id {string|HTMLElement|collection} the element(s) to bind
* @param spec {string} the keyCode and modifier specification
* @param o optional context object
* @param args 0..n additional arguments to provide to the listener.
* @return {Event.Handle} the detach handle
*/
a[0] = 'keypress';
}
// key event type: 'down', 'up', or 'press'
// list of key codes optionally followed by modifiers
// the name of the custom event that will be created for the spec
// subscribe spec validator to the DOM event
// Y.log('keylistener: ' + e.keyCode);
// pass this section if any supplied keyCode
// is found
// Y.log('passed: ' + crit);
passed = true;
} else {
failed = true;
// Y.log('failed: ' + crit);
}
// only check modifier if no keyCode was specified
// or the keyCode check was successful. pass only
// if every modifier passes
// Y.log(crit + ": " + passed);
}
}
// fire spec custom event if spec if met
if (passed) {
}
}, id);
}
// subscribe supplied listener to custom event for spec validator
// remove element and spec.
a[0] = ename;
}
};