event-key-debug.js revision cd9e4415b30cf09a761815cd149ec546ecc1231c
1322N/A * Functionality to listen for one or more specific key combinations. 2644N/A // strip type and modifiers from spec, leaving only keyCodes 1322N/A // FIXME: need to support '65,esc' => keypress, keydown 1322N/A // catch sloppy filters, trailing commas, etc 'a,,' 1322N/A // non-numerics are single characters or key names 1628N/A // FIXME: '65,enter' defaults keydown for both 3853N/A // FIXME: possibly stupid assumption that 3853N/A // the keycode of the lower case == the 3853N/A // charcode of the upper case 3853N/A // a (key:65,char:97), A (key:65,char:65) 1322N/A // upper case chars get +shift free 4552N/A // Note: without specifying any keyCodes, this becomes a 4552N/A // horribly inefficient alias for 'keydown' (et al), but I 4552N/A // can't abort this subscription for a simple 4552N/A // Please use keyCodes or just subscribe directly to keydown, 3853N/A * <p>Add a key listener. The listener will only be notified if the 3853N/A * keystroke detected meets the supplied specification. The 3853N/A * specification is a string that is defined as:</p> 3853N/A * <dd><code>[{type}:]{code}[,{code}]*</dd> 3853N/A * <dd><code>"down", "up", or "press"</code></dd> 3853N/A * <dd><code>{keyCode|character|keyName}[+{modifier}]*</code></dd> 3853N/A * <dd><code>"shift", "ctrl", "alt", or "meta"</code></dd> 3853N/A * <dd><code>"enter", "backspace", "esc", "tab", "pageup", or "pagedown"</code></dd> 3853N/A * <li><code>Y.on("key", callback, "press:12,65+shift+ctrl", "#my-input");</code></li> 3853N/A * <li><code>Y.delegate("key", preventSubmit, "enter", "#forms", "input[type=text]");</code></li> 3853N/A * <li><code>Y.one("doc").on("key", viNav, "j,k,l,;");</code></li> 3853N/A * @param type {string} 'key' 3853N/A * @param fn {function} the function to execute 3853N/A * @param id {string|HTMLElement|collection} the element(s) to bind 3853N/A * @param spec {string} the keyCode and modifier specification 1322N/A * @param o optional context object 1322N/A * @param args 0..n additional arguments to provide to the listener. 4516N/A * @return {Event.Handle} the detach handle