Upgrade to ExtJS 3.1.0 - Released 12/16/2009
[extjs.git] / docs / source / Element.keys.html
1 <html>\r
2 <head>\r
3   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    \r
4   <title>The source code</title>\r
5     <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
6     <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
7 </head>\r
8 <body  onload="prettyPrint();">\r
9     <pre class="prettyprint lang-js">/**\r
10  * @class Ext.Element\r
11  */\r
12 Ext.Element.addMethods({\r
13     <div id="method-Ext.Element-addKeyListener"></div>/**\r
14      * Convenience method for constructing a KeyMap\r
15      * @param {Number/Array/Object/String} key Either a string with the keys to listen for, the numeric key code, array of key codes or an object with the following options:\r
16      * <code>{key: (number or array), shift: (true/false), ctrl: (true/false), alt: (true/false)}</code>\r
17      * @param {Function} fn The function to call\r
18      * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the specified function is executed. Defaults to this Element.\r
19      * @return {Ext.KeyMap} The KeyMap created\r
20      */\r
21     addKeyListener : function(key, fn, scope){\r
22         var config;\r
23         if(!Ext.isObject(key) || Ext.isArray(key)){\r
24             config = {\r
25                 key: key,\r
26                 fn: fn,\r
27                 scope: scope\r
28             };\r
29         }else{\r
30             config = {\r
31                 key : key.key,\r
32                 shift : key.shift,\r
33                 ctrl : key.ctrl,\r
34                 alt : key.alt,\r
35                 fn: fn,\r
36                 scope: scope\r
37             };\r
38         }\r
39         return new Ext.KeyMap(this, config);\r
40     },\r
41 \r
42     <div id="method-Ext.Element-addKeyMap"></div>/**\r
43      * Creates a KeyMap for this element\r
44      * @param {Object} config The KeyMap config. See {@link Ext.KeyMap} for more details\r
45      * @return {Ext.KeyMap} The KeyMap created\r
46      */\r
47     addKeyMap : function(config){\r
48         return new Ext.KeyMap(this, config);\r
49     }\r
50 });</pre>    \r
51 </body>\r
52 </html>