sync
[roojs1] / docs / symbols / Roo.KeyMap.json
1 {
2   "name" : "Roo.KeyMap",
3   "augments" : [],
4   "childClasses" : {  },
5   "tree_children" : [],
6   "tree_parent" : [],
7   "desc" : "Handles mapping keys to actions for an element. One key map can be used for multiple actions.\nThe constructor accepts the same config object as defined by {@link #addBinding}.\nIf you bind a callback function to a KeyMap, anytime the KeyMap handles an expected key\ncombination it will call the function with this signature (if the match is a multi-key\ncombination the callback will still be called only once): (String key, Roo.EventObject e)\nA KeyMap can also handle a string representation of keys.<br />\nUsage:\n <pre><code>\n// map one key by key code\nvar map = new Roo.KeyMap(\"my-element\", {\n    key: 13, // or Roo.EventObject.ENTER\n    fn: myHandler,\n    scope: myObject\n});\n\n// map multiple keys to one action by string\nvar map = new Roo.KeyMap(\"my-element\", {\n    key: \"a\\r\\n\\t\",\n    fn: myHandler,\n    scope: myObject\n});\n\n// map multiple keys to multiple actions by strings and array of codes\nvar map = new Roo.KeyMap(\"my-element\", [\n    {\n        key: [10,13],\n        fn: function(){ alert(\"Return was pressed\"); }\n    }, {\n        key: \"abc\",\n        fn: function(){ alert('a, b or c was pressed'); }\n    }, {\n        key: \"\\t\",\n        ctrl:true,\n        shift:true,\n        fn: function(){ alert('Control + shift + tab was pressed.'); }\n    }\n]);\n</code></pre>\n<b>Note: A KeyMap starts enabled</b>",
8   "isSingleton" : false,
9   "isStatic" : true,
10   "isBuiltin" : false,
11   "isAbstract" : false,
12   "isBuilderTop" : false,
13   "memberOf" : "KeyMap",
14   "example" : "",
15   "deprecated" : "",
16   "since" : "",
17   "see" : "",
18   "params" : [
19     {
20       "name" : "el",
21       "type" : "String/HTMLElement/Roo.Element",
22       "desc" : "The element to bind to",
23       "isOptional" : false
24     },
25     {
26       "name" : "config",
27       "type" : "Object",
28       "desc" : "The config (see {@link #addBinding})",
29       "isOptional" : false
30     },
31     {
32       "name" : "eventName",
33       "type" : "String",
34       "desc" : "(optional) The event to bind to (defaults to \"keydown\")",
35       "isOptional" : false
36     }
37   ],
38   "returns" : [],
39   "throws" : "",
40   "requires" : "",
41   "config" : [],
42   "methods" : [
43     {
44       "name" : "on",
45       "type" : "function",
46       "desc" : "Shorthand for adding a single key listener",
47       "sig" : "(key, fn, scope)",
48       "static" : false,
49       "memberOf" : "",
50       "isStatic" : false,
51       "isConstructor" : false,
52       "isPrivate" : false,
53       "example" : "",
54       "deprecated" : "",
55       "since" : "",
56       "see" : "",
57       "exceptions" : "",
58       "requires" : "",
59       "params" : [
60         {
61           "name" : "key",
62           "type" : "Number/Array/Object",
63           "desc" : "Either the numeric key code, array of key codes or an object with the\nfollowing options:\n{key: (number or array), shift: (true/false), ctrl: (true/false), alt: (true/false)}",
64           "isOptional" : false
65         },
66         {
67           "name" : "fn",
68           "type" : "Function",
69           "desc" : "The function to call",
70           "isOptional" : false
71         },
72         {
73           "name" : "scope",
74           "type" : "Object",
75           "desc" : "(optional) The scope of the function",
76           "isOptional" : false
77         }
78       ],
79       "returns" : []
80     },
81     {
82       "name" : "disable",
83       "type" : "function",
84       "desc" : "Disable this KeyMap",
85       "sig" : "()\n{\n\n}",
86       "static" : false,
87       "memberOf" : "",
88       "isStatic" : false,
89       "isConstructor" : false,
90       "isPrivate" : false,
91       "example" : "",
92       "deprecated" : "",
93       "since" : "",
94       "see" : "",
95       "exceptions" : "",
96       "requires" : "",
97       "params" : [],
98       "returns" : []
99     },
100     {
101       "name" : "isEnabled",
102       "type" : "function",
103       "desc" : "Returns true if this KeyMap is enabled",
104       "sig" : "()\n{\n\n}",
105       "static" : false,
106       "memberOf" : "",
107       "isStatic" : false,
108       "isConstructor" : false,
109       "isPrivate" : false,
110       "example" : "",
111       "deprecated" : "",
112       "since" : "",
113       "see" : "",
114       "exceptions" : "",
115       "requires" : "",
116       "params" : [],
117       "returns" : [
118         {
119           "name" : "",
120           "type" : "Boolean",
121           "desc" : ""
122         }
123       ]
124     },
125     {
126       "name" : "enable",
127       "type" : "function",
128       "desc" : "Enables this KeyMap",
129       "sig" : "()\n{\n\n}",
130       "static" : false,
131       "memberOf" : "",
132       "isStatic" : false,
133       "isConstructor" : false,
134       "isPrivate" : false,
135       "example" : "",
136       "deprecated" : "",
137       "since" : "",
138       "see" : "",
139       "exceptions" : "",
140       "requires" : "",
141       "params" : [],
142       "returns" : []
143     },
144     {
145       "name" : "addBinding",
146       "type" : "function",
147       "desc" : "Add a new binding to this KeyMap. The following config object properties are supported:\n<pre>\nProperty    Type             Description\n----------  ---------------  ----------------------------------------------------------------------\nkey         String/Array     A single keycode or an array of keycodes to handle\nshift       Boolean          True to handle key only when shift is pressed (defaults to false)\nctrl        Boolean          True to handle key only when ctrl is pressed (defaults to false)\nalt         Boolean          True to handle key only when alt is pressed (defaults to false)\nfn          Function         The function to call when KeyMap finds the expected key combination\nscope       Object           The scope of the callback function\n</pre>\n\nUsage:\n<pre><code>\n// Create a KeyMap\nvar map = new Roo.KeyMap(document, {\n    key: Roo.EventObject.ENTER,\n    fn: handleKey,\n    scope: this\n});\n\n//Add a new binding to the existing KeyMap later\nmap.addBinding({\n    key: 'abc',\n    shift: true,\n    fn: handleKey,\n    scope: this\n});\n</code></pre>",
148       "sig" : "(config)",
149       "static" : false,
150       "memberOf" : "",
151       "isStatic" : false,
152       "isConstructor" : false,
153       "isPrivate" : false,
154       "example" : "",
155       "deprecated" : "",
156       "since" : "",
157       "see" : "",
158       "exceptions" : "",
159       "requires" : "",
160       "params" : [
161         {
162           "name" : "config",
163           "type" : "Object/Array",
164           "desc" : "A single KeyMap config or an array of configs",
165           "isOptional" : false
166         }
167       ],
168       "returns" : []
169     }
170   ],
171   "events" : []
172 }