source: trunk/web/addons/job_monarch/lib/extjs-30/src/core/Element.keys.js @ 625

Last change on this file since 625 was 625, checked in by ramonb, 15 years ago

lib/extjs-30:

  • new ExtJS 3.0
File size: 1.5 KB
Line 
1/*!
2 * Ext JS Library 3.0.0
3 * Copyright(c) 2006-2009 Ext JS, LLC
4 * licensing@extjs.com
5 * http://www.extjs.com/license
6 */
7/**
8 * @class Ext.Element
9 */
10Ext.Element.addMethods({
11    /**
12     * Convenience method for constructing a KeyMap
13     * @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:
14     *                                  {key: (number or array), shift: (true/false), ctrl: (true/false), alt: (true/false)}
15     * @param {Function} fn The function to call
16     * @param {Object} scope (optional) The scope of the function
17     * @return {Ext.KeyMap} The KeyMap created
18     */
19    addKeyListener : function(key, fn, scope){
20        var config;
21        if(!Ext.isObject(key) || Ext.isArray(key)){
22            config = {
23                key: key,
24                fn: fn,
25                scope: scope
26            };
27        }else{
28            config = {
29                key : key.key,
30                shift : key.shift,
31                ctrl : key.ctrl,
32                alt : key.alt,
33                fn: fn,
34                scope: scope
35            };
36        }
37        return new Ext.KeyMap(this, config);
38    },
39
40    /**
41     * Creates a KeyMap for this element
42     * @param {Object} config The KeyMap config. See {@link Ext.KeyMap} for more details
43     * @return {Ext.KeyMap} The KeyMap created
44     */
45    addKeyMap : function(config){
46        return new Ext.KeyMap(this, config);
47    }
48});
Note: See TracBrowser for help on using the repository browser.