diff options
author | Valerio Virgillito | 2012-05-16 15:23:48 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-05-16 15:23:48 -0700 |
commit | 13ae16997d4bbca14e255d5989d1c44a76eac72c (patch) | |
tree | d9ebb1dcc6bebee4cb910b950ecb67c1a2d593cd /node_modules/montage/core/event/key-manager.js | |
parent | 99f16ae08fbb0a6dfe6008c9833f2253b18c19e5 (diff) | |
download | ninja-13ae16997d4bbca14e255d5989d1c44a76eac72c.tar.gz |
montage v.0.10 integration
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'node_modules/montage/core/event/key-manager.js')
-rw-r--r-- | node_modules/montage/core/event/key-manager.js | 978 |
1 files changed, 978 insertions, 0 deletions
diff --git a/node_modules/montage/core/event/key-manager.js b/node_modules/montage/core/event/key-manager.js new file mode 100644 index 00000000..c5728b06 --- /dev/null +++ b/node_modules/montage/core/event/key-manager.js | |||
@@ -0,0 +1,978 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | /** | ||
7 | @module montage/core/event/key-manager | ||
8 | @requires montage/core/core | ||
9 | */ | ||
10 | |||
11 | var Montage = require("montage").Montage, | ||
12 | defaultEventManager = require("core/event/event-manager").defaultEventManager, | ||
13 | MutableEvent = require("core/event/mutable-event").MutableEvent; | ||
14 | |||
15 | var KEYNAMES_TO_KEYCODES = { | ||
16 | // W3C Key Code | ||
17 | backspace: 8, | ||
18 | tab: 9, | ||
19 | enter: 13, | ||
20 | shift: 16, | ||
21 | control: 17, | ||
22 | alt: 18, | ||
23 | capslock: 20, | ||
24 | escape: 27, | ||
25 | space: 32, | ||
26 | pageup: 33, | ||
27 | pagedown: 34, | ||
28 | end: 35, | ||
29 | home: 36, | ||
30 | left: 37, | ||
31 | up: 38, | ||
32 | right: 39, | ||
33 | down: 40, | ||
34 | delete: 46, | ||
35 | |||
36 | // W3C Optional Key Code (mostly for US keyboard layout) | ||
37 | semicolon: 186, | ||
38 | colon: 186, | ||
39 | equal: 187, | ||
40 | plus: 187, | ||
41 | comma: 188, | ||
42 | less: 188, | ||
43 | minus: 189, | ||
44 | underscore: 189, | ||
45 | period: 190, | ||
46 | greater: 190, | ||
47 | slash: 191, | ||
48 | questionmark: 191, | ||
49 | backtick: 192, | ||
50 | tilde: 192, | ||
51 | openingsquarebracket: 219, | ||
52 | openingcurlybracket: 219, | ||
53 | backslash: 220, | ||
54 | pipe: 220, | ||
55 | closingsquarebracket: 221, | ||
56 | closingcurlybracket: 221, | ||
57 | singlequote: 222, | ||
58 | doublequote: 222, | ||
59 | |||
60 | |||
61 | // Non standard Virtal key code but commonly used | ||
62 | clear: 12, | ||
63 | meta: 91, | ||
64 | contextmenu: 93, | ||
65 | numpad0: 96, | ||
66 | numpad1: 97, | ||
67 | numpad2: 98, | ||
68 | numpad3: 99, | ||
69 | numpad4: 100, | ||
70 | numpad5: 101, | ||
71 | numpad6: 102, | ||
72 | numpad7: 103, | ||
73 | numpad8: 104, | ||
74 | numpad9: 105, | ||
75 | multiply: 106, | ||
76 | add: 107, | ||
77 | subtract: 109, | ||
78 | decimal: 110, | ||
79 | divide: 111, | ||
80 | f1: 112, | ||
81 | f2: 113, | ||
82 | f3: 114, | ||
83 | f4: 115, | ||
84 | f5: 116, | ||
85 | f6: 117, | ||
86 | f7: 118, | ||
87 | f8: 119, | ||
88 | f9: 120, | ||
89 | f10: 121, | ||
90 | f11: 122, | ||
91 | f12: 123, | ||
92 | f13: 124, | ||
93 | f14: 125, | ||
94 | f15: 126, | ||
95 | f16: 127, | ||
96 | f17: 128, | ||
97 | f18: 129, | ||
98 | f19: 130, | ||
99 | f20: 131, | ||
100 | f21: 132, | ||
101 | f22: 133, | ||
102 | f23: 134, | ||
103 | f24: 135 | ||
104 | }, | ||
105 | |||
106 | KEYCODES_TO_KEYNAMES = null, // Will be build from the KEYNAMES_TO_KEYCODES dictionary | ||
107 | |||
108 | OPERAMAC_KEYNAMES_TO_KEYCODES = { | ||
109 | meta: 17, | ||
110 | control: 57392, | ||
111 | f17: 63252, | ||
112 | f18: 63253, | ||
113 | f19: 63254, | ||
114 | f20: 63255, | ||
115 | f21: 63256, | ||
116 | f22: 63257, | ||
117 | f23: 63258, | ||
118 | f24: 63259 | ||
119 | }, | ||
120 | |||
121 | FIREFOX_KEYNAMES_TO_KEYCODES = { | ||
122 | f13: 44, | ||
123 | f14: 145, | ||
124 | f15: 19, | ||
125 | f16: 63251, | ||
126 | f17: 63252, | ||
127 | f18: 63253, | ||
128 | f19: 63254, | ||
129 | f20: 63255, | ||
130 | f21: 63256, | ||
131 | f22: 63257, | ||
132 | f23: 63258, | ||
133 | f24: 63259, | ||
134 | meta: 224 | ||
135 | }, | ||
136 | |||
137 | KEYNAMES_ALIASES = { | ||
138 | cmd: "command", | ||
139 | ctl: "control", | ||
140 | ctrl: "control", | ||
141 | win: "meta", | ||
142 | windows: "meta", | ||
143 | opt: "alt", | ||
144 | option: "alt" | ||
145 | }, | ||
146 | |||
147 | MODIFIERS = { | ||
148 | meta: {name:"meta", value:1}, | ||
149 | alt: {name:"alt", value:2}, | ||
150 | control: {name:"control", value:4}, | ||
151 | shift: {name:"shift", value:8} | ||
152 | }, | ||
153 | |||
154 | NORMALIZED_KEYS = { | ||
155 | semicolon: ";", | ||
156 | colon: ":", | ||
157 | equal: "=", | ||
158 | plus: "+", | ||
159 | comma: ",", | ||
160 | less: "<", | ||
161 | minus: "-", | ||
162 | underscore: "_", | ||
163 | period: ".", | ||
164 | greater: ">", | ||
165 | slash: "/", | ||
166 | questionmark: "?", | ||
167 | backtick: "`", | ||
168 | tilde: "~", | ||
169 | openingsquarebracket: "[", | ||
170 | openingcurlybracket: "{", | ||
171 | backslash: "\\", | ||
172 | pipe: "|", | ||
173 | closingsquarebracket: "]", | ||
174 | closingcurlybracket: "}", | ||
175 | singlequote: "'", | ||
176 | doublequote: "\"", | ||
177 | multiply: "*", | ||
178 | add: "+", | ||
179 | subtract: "-", | ||
180 | decimal: ".", | ||
181 | divide: "/" | ||
182 | }, | ||
183 | |||
184 | NORMALIZED_CHARS = null; // Will be generated from the NORMALIZED_KEYS | ||
185 | |||
186 | |||
187 | /* Event type dispatched by KeyComposer */ | ||
188 | var KEYPRESS_EVENT_TYPE = "keyPress", | ||
189 | LONGKEYPRESS_EVENT_TYPE = "longKeyPress", | ||
190 | KEYRELEASE_EVENT_TYPE = "keyRelease"; | ||
191 | |||
192 | |||
193 | /** | ||
194 | @class module:montage/core/event/key-manager.KeyManager | ||
195 | @classdesc The KeyManager dispatches KeyComposer events when it detects a keyComposer has been pressed or released. | ||
196 | Do not create a KeyManager directly but instead require for the defaultKeyManager: require("core/event/key-manager").defaultKeyManager | ||
197 | @extends module:montage/core/core.Montage | ||
198 | */ | ||
199 | var KeyManager = exports.KeyManager = Montage.create(Montage,/** @lends module:montage/core/event/key-manager.KeyManager# */ { | ||
200 | |||
201 | /** | ||
202 | @private | ||
203 | */ | ||
204 | _keyEventsListenerInstalled: { | ||
205 | value: false | ||
206 | }, | ||
207 | |||
208 | /** | ||
209 | @private | ||
210 | */ | ||
211 | _composerKeyMap: { | ||
212 | value: {} | ||
213 | }, | ||
214 | |||
215 | /** | ||
216 | @private | ||
217 | */ | ||
218 | _triggeredKeys: { | ||
219 | value: {} | ||
220 | }, | ||
221 | |||
222 | /** | ||
223 | @private | ||