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