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