summaryrefslogtreecommitdiff
path: root/webapps/qooxdoo-0.6.5-sdk/frontend/framework/source/class/qx/event/type/KeyEvent.js
blob: eb69c51242a5775c743b380e51fd7a5911a91b71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
/* ************************************************************************

   qooxdoo - the new era of web development

   http://qooxdoo.org

   Copyright:
     2004-2007 1&1 Internet AG, Germany, http://www.1and1.org

   License:
     LGPL: http://www.gnu.org/licenses/lgpl.html
     EPL: http://www.eclipse.org/org/documents/epl-v10.php
     See the LICENSE file in the project's top-level directory for details.

   Authors:
     * Sebastian Werner (wpbasti)
     * Andreas Ecker (ecker)
     * Fabian Jakobs (fjakobs)

************************************************************************ */

/* ************************************************************************

#module(ui_core)

************************************************************************ */

/**
 * A key event instance contains all data for each occured key event
 *
 * @param vType {String} event type (keydown, keypress, keyinput, keyup)
 * @param vDomEvent {Element} DOM event object
 * @param vDomTarget {Element} target element of the DOM event
 * @param vTarget
 * @param vOriginalTarget
 * @param vKeyCode {Integer} emulated key code for compatibility with older qoodoo applications
 * @param vCharCode {Integer} char code from the "keypress" event
 * @param vKeyIdentifier {String} the key identifier
 */
qx.OO.defineClass("qx.event.type.KeyEvent", qx.event.type.DomEvent,
function(vType, vDomEvent, vDomTarget, vTarget, vOriginalTarget, vKeyCode, vCharCode, vKeyIdentifier)
{
  qx.event.type.DomEvent.call(this, vType, vDomEvent, vDomTarget, vTarget, vOriginalTarget);

  this.setKeyCode(vKeyCode);
  this.setCharCode(vCharCode);
  this.setKeyIdentifier(vKeyIdentifier);
});

/**
 * Legacy keycode
 * @deprecated Will be removed with qooxdoo 0.7
 */
qx.OO.addFastProperty({ name : "keyCode", setOnlyOnce : true, noCompute : true });

/**
 * Unicode number of the pressed character.
 * Only valid in "keyinput" events
 */
qx.OO.addFastProperty({ name : "charCode", setOnlyOnce : true, noCompute : true });

/**
 * Identifier of the pressed key. This property is modeled after the <em>KeyboardEvent.keyIdentifier</em> property
 * of the W3C DOM 3 event specification (http://www.w3.org/TR/2003/NOTE-DOM-Level-3-Events-20031107/events.html#Events-KeyboardEvent-keyIdentifier).
 *
 * It is not valid in "keyinput" events"
 *
 * Printable keys are represented by a unicode string, non-printable keys have one of the following
 * values:
 * <br>
 * <table>
 * <tr><th>Backspace</th><td>The Backspace (Back) key.</td></tr>
 * <tr><th>Tab</th><td>The Horizontal Tabulation (Tab) key.</td></tr>
 * <tr><th>Space</th><td>The Space (Spacebar) key.</td></tr>
 * <tr><th>Enter</th><td>The Enter key. Note: This key identifier is also used for the Return (Macintosh numpad) key.</td></tr>
 * <tr><th>Shift</th><td>The Shift key.</td></tr>
 * <tr><th>Control</th><td>The Control (Ctrl) key.</td></tr>
 * <tr><th>Alt</th><td>The Alt (Menu) key.</td></tr>
 * <tr><th>CapsLock</th><td>The CapsLock key</td></tr>
 * <tr><th>Meta</th><td>The Meta key. (Apple Meta and Windows key)</td></tr>
 * <tr><th>Escape</th><td>The Escape (Esc) key.</td></tr>
 * <tr><th>Left</th><td>The Left Arrow key.</td></tr>
 * <tr><th>Up</th><td>The Up Arrow key.</td></tr>
 * <tr><th>Right</th><td>The Right Arrow key.</td></tr>
 * <tr><th>Down</th><td>The Down Arrow key.</td></tr>
 * <tr><th>PageUp</th><td>The Page Up key.</td></tr>
 * <tr><th>PageDown</th><td>The Page Down (Next) key.</td></tr>
 * <tr><th>End</th><td>The End key.</td></tr>
 * <tr><th>Home</th><td>The Home key.</td></tr>
 * <tr><th>Insert</th><td>The Insert (Ins) key. (Does not fire in Opera/Win)</td></tr>
 * <tr><th>Delete</th><td>The Delete (Del) Key.</td></tr>
 * <tr><th>F1</th><td>The F1 key.</td></tr>
 * <tr><th>F2</th><td>The F2 key.</td></tr>
 * <tr><th>F3</th><td>The F3 key.</td></tr>
 * <tr><th>F4</th><td>The F4 key.</td></tr>
 * <tr><th>F5</th><td>The F5 key.</td></tr>
 * <tr><th>F6</th><td>The F6 key.</td></tr>
 * <tr><th>F7</th><td>The F7 key.</td></tr>
 * <tr><th>F8</th><td>The F8 key.</td></tr>
 * <tr><th>F9</th><td>The F9 key.</td></tr>
 * <tr><th>F10</th><td>The F10 key.</td></tr>
 * <tr><th>F11</th><td>The F11 key.</td></tr>
 * <tr><th>F12</th><td>The F12 key.</td></tr>
 * <tr><th>NumLock</th><td>The Num Lock key.</td></tr>
 * <tr><th>PrintScreen</th><td>The Print Screen (PrintScrn, SnapShot) key.</td></tr>
 * <tr><th>Scroll</th><td>The scroll lock key</td></tr>
 * <tr><th>Pause</th><td>The pause/break key</td></tr>
 * <tr><th>Win</th><td>The Windows Logo key</td></tr>
 * <tr><th>Apps</th><td>The Application key (Windows Context Menu)</td></tr>
 * </table>
 */
qx.OO.addFastProperty({ name : "keyIdentifier", setOnlyOnce : true, noCompute : true });








/* ************************************************************************
   Class data, properties and methods
************************************************************************ */

/*
---------------------------------------------------------------------------
  CLASS PROPERTIES AND METHODS
---------------------------------------------------------------------------
*/

/**
 * Mapping of the old key identifiers to the key codes
 * @deprecated
 */
qx.event.type.KeyEvent.keys =
{
  esc : 27,
  enter : 13,
  tab : 9,
  space : 32,

  up : 38,
  down : 40,
  left : 37,
  right : 39,

  shift : 16,
  ctrl : 17,
  alt : 18,

  f1 : 112,
  f2 : 113,
  f3 : 114,
  f4 : 115,
  f5 : 116,
  f6 : 117,
  f7 : 118,
  f8 : 119,
  f9 : 120,
  f10 : 121,
  f11 : 122,
  f12 : 123,

  print : 124,

  del : 46,
  backspace : 8,
  insert : 45,
  home : 36,
  end : 35,

  pageup : 33,
  pagedown : 34,

  numlock : 144,

  numpad_0 : 96,
  numpad_1 : 97,
  numpad_2 : 98,
  numpad_3 : 99,
  numpad_4 : 100,
  numpad_5 : 101,
  numpad_6 : 102,
  numpad_7 : 103,
  numpad_8 : 104,
  numpad_9 : 105,

  numpad_divide : 111,
  numpad_multiply : 106,
  numpad_minus : 109,
  numpad_plus : 107
};

// create dynamic codes copy
(function() {
  qx.event.type.KeyEvent.codes = {};
  for (var i in qx.event.type.KeyEvent.keys) {
    qx.event.type.KeyEvent.codes[qx.event.type.KeyEvent.keys[i]] = i;
  }
})();