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