KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > dom > events > DOMKeyEvent


1 /*
2
3    Copyright 2002 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.dom.events;
19
20 import org.w3c.dom.views.AbstractView;
21
22 /**
23  * The <code>KeyEvent</code> interface provides specific contextual
24  * information associated with Key events.
25  *
26  * @since DOM Level 2 (Working Draft)
27  */

28 public class DOMKeyEvent extends DOMUIEvent {
29
30     // VirtualKeyCode
31
public static final int CHAR_UNDEFINED = 0x0FFFF;
32     public static final int DOM_VK_0 = 0x30;
33     public static final int DOM_VK_1 = 0x31;
34     public static final int DOM_VK_2 = 0x32;
35     public static final int DOM_VK_3 = 0x33;
36     public static final int DOM_VK_4 = 0x34;
37     public static final int DOM_VK_5 = 0x35;
38     public static final int DOM_VK_6 = 0x36;
39     public static final int DOM_VK_7 = 0x37;
40     public static final int DOM_VK_8 = 0x38;
41     public static final int DOM_VK_9 = 0x39;
42     public static final int DOM_VK_A = 0x41;
43     public static final int DOM_VK_ACCEPT = 0x1E;
44     public static final int DOM_VK_ADD = 0x6B;
45     public static final int DOM_VK_AGAIN = 0xFFC9;
46     public static final int DOM_VK_ALL_CANDIDATES = 0x0100;
47     public static final int DOM_VK_ALPHANUMERIC = 0x00F0;
48     public static final int DOM_VK_ALT = 0x12;
49     public static final int DOM_VK_ALT_GRAPH = 0xFF7E;
50     public static final int DOM_VK_AMPERSAND = 0x96;
51     public static final int DOM_VK_ASTERISK = 0x97;
52     public static final int DOM_VK_AT = 0x0200;
53     public static final int DOM_VK_B = 0x42;
54     public static final int DOM_VK_BACK_QUOTE = 0xC0;
55     public static final int DOM_VK_BACK_SLASH = 0x5C;
56     public static final int DOM_VK_BACK_SPACE = 0x08;
57     public static final int DOM_VK_BRACELEFT = 0xA1;
58     public static final int DOM_VK_BRACERIGHT = 0xA2;
59     public static final int DOM_VK_C = 0x43;
60     public static final int DOM_VK_CANCEL = 0x03;
61     public static final int DOM_VK_CAPS_LOCK = 0x14;
62     public static final int DOM_VK_CIRCUMFLEX = 0x0202;
63     public static final int DOM_VK_CLEAR = 0x0C;
64     public static final int DOM_VK_CLOSE_BRACKET = 0x5D;
65     public static final int DOM_VK_CODE_INPUT = 0x0102;
66     public static final int DOM_VK_COLON = 0x0201;
67     public static final int DOM_VK_COMMA = 0x2C;
68     public static final int DOM_VK_COMPOSE = 0xFF20;
69     public static final int DOM_VK_CONTROL = 0x11;
70     public static final int DOM_VK_CONVERT = 0x1C;
71     public static final int DOM_VK_COPY = 0xFFCD;
72     public static final int DOM_VK_CUT = 0xFFD1;
73     public static final int DOM_VK_D = 0x44;
74     public static final int DOM_VK_DEAD_ABOVEDOT = 0x86;
75     public static final int DOM_VK_DEAD_ABOVERING = 0x88;
76     public static final int DOM_VK_DEAD_ACUTE = 0x81;
77     public static final int DOM_VK_DEAD_BREVE = 0x85;
78     public static final int DOM_VK_DEAD_CARON = 0x8A;
79     public static final int DOM_VK_DEAD_CEDILLA = 0x8B;
80     public static final int DOM_VK_DEAD_CIRCUMFLEX = 0x82;
81     public static final int DOM_VK_DEAD_DIAERESIS = 0x87;
82     public static final int DOM_VK_DEAD_DOUBLEACUTE = 0x89;
83     public static final int DOM_VK_DEAD_GRAVE = 0x80;
84     public static final int DOM_VK_DEAD_IOTA = 0x8D;
85     public static final int DOM_VK_DEAD_MACRON = 0x84;
86     public static final int DOM_VK_DEAD_OGONEK = 0x8C;
87     public static final int DOM_VK_DEAD_SEMIVOICED_SOUND = 0x8F;
88     public static final int DOM_VK_DEAD_TILDE = 0x83;
89     public static final int DOM_VK_DEAD_VOICED_SOUND = 0x8E;
90     public static final int DOM_VK_DECIMAL = 0x6E;
91     public static final int DOM_VK_DELETE = 0x7F;
92     public static final int DOM_VK_DIVIDE = 0x6F;
93     public static final int DOM_VK_DOLLAR = 0x0203;
94     public static final int DOM_VK_DOWN = 0x28;
95     public static final int DOM_VK_E = 0x45;
96     public static final int DOM_VK_END = 0x23;
97     public static final int DOM_VK_ENTER = 0x0D;
98     public static final int DOM_VK_EQUALS = 0x3D;
99     public static final int DOM_VK_ESCAPE = 0x1B;
100     public static final int DOM_VK_EURO_SIGN = 0x0204;
101     public static final int DOM_VK_EXCLAMATION_MARK = 0x0205;
102     public static final int DOM_VK_F = 0x46;
103     public static final int DOM_VK_F1 = 0x70;
104     public static final int DOM_VK_F10 = 0x79;
105     public static final int DOM_VK_F11 = 0x7A;
106     public static final int DOM_VK_F12 = 0x7B;
107     public static final int DOM_VK_F13 = 0xF000;
108     public static final int DOM_VK_F14 = 0xF001;
109     public static final int DOM_VK_F15 = 0xF002;
110     public static final int DOM_VK_F16 = 0xF003;
111     public static final int DOM_VK_F17 = 0xF004;
112     public static final int DOM_VK_F18 = 0xF005;
113     public static final int DOM_VK_F19 = 0xF006;
114     public static final int DOM_VK_F2 = 0x71;
115     public static final int DOM_VK_F20 = 0xF007;
116     public static final int DOM_VK_F21 = 0xF008;
117     public static final int DOM_VK_F22 = 0xF009;
118     public static final int DOM_VK_F23 = 0xF00A;
119     public static final int DOM_VK_F24 = 0xF00B;
120     public static final int DOM_VK_F3 = 0x72;
121     public static final int DOM_VK_F4 = 0x73;
122     public static final int DOM_VK_F5 = 0x74;
123     public static final int DOM_VK_F6 = 0x75;
124     public static final int DOM_VK_F7 = 0x76;
125     public static final int DOM_VK_F8 = 0x77;
126     public static final int DOM_VK_F9 = 0x78;
127     public static final int DOM_VK_FINAL = 0x18;
128     public static final int DOM_VK_FIND = 0xFFD0;
129     public static final int DOM_VK_FULL_WIDTH = 0x00F3;
130     public static final int DOM_VK_G = 0x47;
131     public static final int DOM_VK_GREATER = 0xA0;
132     public static final int DOM_VK_H = 0x48;
133     public static final int DOM_VK_HALF_WIDTH = 0x00F4;
134     public static final int DOM_VK_HELP = 0x9C;
135     public static final int DOM_VK_HIRAGANA = 0x00F2;
136     public static final int DOM_VK_HOME = 0x24;
137     public static final int DOM_VK_I = 0x49;
138     public static final int DOM_VK_INSERT = 0x9B;
139     public static final int DOM_VK_INVERTED_EXCLAMATION_MARK = 0x0206;
140     public static final int DOM_VK_J = 0x4A;
141     public static final int DOM_VK_JAPANESE_HIRAGANA = 0x0104;
142     public static final int DOM_VK_JAPANESE_KATAKANA = 0x0103;
143     public static final int DOM_VK_JAPANESE_ROMAN = 0x0105;
144     public static final int DOM_VK_K = 0x4B;
145     public static final int DOM_VK_KANA = 0x15;
146     public static final int DOM_VK_KANJI = 0x19;
147     public static final int DOM_VK_KATAKANA = 0x00F1;
148     public static final int DOM_VK_KP_DOWN = 0xE1;
149     public static final int DOM_VK_KP_LEFT = 0xE2;
150     public static final int DOM_VK_KP_RIGHT = 0xE3;
151     public static final int DOM_VK_KP_UP = 0xE0;
152     public static final int DOM_VK_L = 0x4C;
153     public static final int DOM_VK_LEFT = 0x25;
154     public static final int DOM_VK_LEFT_PARENTHESIS = 0x0207;
155     public static final int DOM_VK_LESS = 0x99;
156     public static final int DOM_VK_M = 0x4D;
157     public static final int DOM_VK_META = 0x9D;
158     public static final int DOM_VK_MINUS = 0x2D;
159     public static final int DOM_VK_MODECHANGE = 0x1F;
160     public static final int DOM_VK_MULTIPLY = 0x6A;
161     public static final int DOM_VK_N = 0x4E;
162     public static final int DOM_VK_NONCONVERT = 0x1D;
163     public static final int DOM_VK_NUM_LOCK = 0x90;
164     public static final int DOM_VK_NUMBER_SIGN = 0x0208;
165     public static final int DOM_VK_NUMPAD0 = 0x60;
166     public static final int DOM_VK_NUMPAD1 = 0x61;
167     public static final int DOM_VK_NUMPAD2 = 0x62;
168     public static final int DOM_VK_NUMPAD3 = 0x63;
169     public static final int DOM_VK_NUMPAD4 = 0x64;
170     public static final int DOM_VK_NUMPAD5 = 0x65;
171     public static final int DOM_VK_NUMPAD6 = 0x66;
172     public static final int DOM_VK_NUMPAD7 = 0x67;
173     public static final int DOM_VK_NUMPAD8 = 0x68;
174     public static final int DOM_VK_NUMPAD9 = 0x69;
175     public static final int DOM_VK_O = 0x4F;
176     public static final int DOM_VK_OPEN_BRACKET = 0x5B;
177     public static final int DOM_VK_P = 0x50;
178     public static final int DOM_VK_PAGE_DOWN = 0x22;
179     public static final int DOM_VK_PAGE_UP = 0x21;
180     public static final int DOM_VK_PASTE = 0xFFCF;
181     public static final int DOM_VK_PAUSE = 0x13;
182     public static final int DOM_VK_PERIOD = 0x2E;
183     public static final int DOM_VK_PLUS = 0x0209;
184     public static final int DOM_VK_PREVIOUS_CANDIDATE = 0x0101;
185     public static final int DOM_VK_PRINTSCREEN = 0x9A;
186     public static final int DOM_VK_PROPS = 0xFFCA;
187     public static final int DOM_VK_Q = 0x51;
188     public static final int DOM_VK_QUOTE = 0xDE;
189     public static final int DOM_VK_QUOTEDBL = 0x98;
190     public static final int DOM_VK_R = 0x52;
191     public static final int DOM_VK_RIGHT = 0x27;
192     public static final int DOM_VK_RIGHT_PARENTHESIS = 0x020A;
193     public static final int DOM_VK_ROMAN_CHARACTERS = 0x00F5;
194     public static final int DOM_VK_S = 0x53;
195     public static final int DOM_VK_SCROLL_LOCK = 0x91;
196     public static final int DOM_VK_SEMICOLON = 0x3B;
197     public static final int DOM_VK_SEPARATER = 0x6C;
198     public static final int DOM_VK_SHIFT = 0x10;
199     public static final int DOM_VK_SLASH = 0x2F;
200     public static final int DOM_VK_SPACE = 0x20;
201     public static final int DOM_VK_STOP = 0xFFC8;
202     public static final int DOM_VK_SUBTRACT = 0x6D;
203     public static final int DOM_VK_T = 0x54;
204     public static final int DOM_VK_TAB = 0x09;
205     public static final int DOM_VK_U = 0x55;
206     public static final int DOM_VK_UNDEFINED = 0x0;
207     public static final int DOM_VK_UNDERSCORE = 0x020B;
208     public static final int DOM_VK_UNDO = 0xFFCB;
209     public static final int DOM_VK_UP = 0x26;
210     public static final int DOM_VK_V = 0x56;
211     public static final int DOM_VK_W = 0x57;
212     public static final int DOM_VK_X = 0x58;
213     public static final int DOM_VK_Y = 0x59;
214     public static final int DOM_VK_Z = 0x5A;
215
216     protected boolean ctrlKey;
217     protected boolean altKey;
218     protected boolean shiftKey;
219     protected boolean metaKey;
220     protected int keyCode;
221     protected int charCode;
222
223     /**
224      * Returns whether the 'ctrl' key was depressed during the firing of the
225      * event.
226      */

227     public boolean getCtrlKey() {
228         return ctrlKey;
229     }
230
231     /**
232      * Returns whether the 'shift' key was depressed during the firing of the
233      * event.
234      */

235     public boolean getShiftKey() {
236         return shiftKey;
237     }
238
239     /**
240      * Returns whether the 'alt' key was depressed during the firing of the
241      * event. On some platforms this key may map to an alternative key name.
242      */

243     public boolean getAltKey() {
244         return altKey;
245     }
246
247     /**
248      * Returns whether the 'meta' key was depressed during the firing of
249      * the event. On some platforms this key may map to an alternative
250      * key name.
251      */

252     public boolean getMetaKey() {
253         return metaKey;
254     }
255
256     /**
257      * Returns the virtual key code value of the key which was depressed
258      * if the event is a key event. Otherwise, the value returned is zero.
259      */

260     public int getKeyCode() {
261         return keyCode;
262     }
263
264     /**
265      * Returns the value of the Unicode character associated with the
266      * depressed key if the event is a key event. Otherwise, the value
267      * returned is zero.
268      */

269     public int getCharCode() {
270         return charCode;
271     }
272
273     /**
274      * Initializes this KeyEvent.
275      * @param typeArg Specifies the event type.
276      * @param canBubbleArg Specifies whether or not the event can bubble.
277      * @param cancelableArg Specifies whether or not the event's default action
278      * can be prevent.
279      * @param ctrlKeyArg Specifies whether or not control key was depressed
280      * during the <code>Event</code>.
281      * @param altKeyArg Specifies whether or not alt key was depressed during
282      * the <code>Event</code>.
283      * @param shiftKeyArg Specifies whether or not shift key was depressed
284      * during the <code>Event</code>.
285      * @param metaKeyArg Specifies whether or not meta key was depressed during
286      * the <code>Event</code>.
287      * @param keyCodeArg Specifies the <code>Event</code>'s <code>keyCode</code>
288      * @param charCodeArg Specifies the <code>Event</code>'s
289      * <code>charCode</code>
290      * @param viewArg Specifies the <code>Event</code>'s
291      * <code>AbstractView</code>.
292      */

293     public void initKeyEvent(String JavaDoc typeArg,
294                              boolean canBubbleArg,
295                              boolean cancelableArg,
296                              boolean ctrlKeyArg,
297                              boolean altKeyArg,
298                              boolean shiftKeyArg,
299                              boolean metaKeyArg,
300                              int keyCodeArg,
301                              int charCodeArg,
302                              AbstractView viewArg) {
303     initUIEvent(typeArg, canBubbleArg, cancelableArg, viewArg, 0);
304         ctrlKey = ctrlKeyArg;
305         altKey = altKeyArg;
306         shiftKey = shiftKeyArg;
307         metaKey = metaKeyArg;
308         keyCode = keyCodeArg;
309         charCode = charCodeArg;
310     }
311 }
312
313
Popular Tags