001: /*
002:
003: Licensed to the Apache Software Foundation (ASF) under one or more
004: contributor license agreements. See the NOTICE file distributed with
005: this work for additional information regarding copyright ownership.
006: The ASF licenses this file to You under the Apache License, Version 2.0
007: (the "License"); you may not use this file except in compliance with
008: the License. You may obtain a copy of the License at
009:
010: http://www.apache.org/licenses/LICENSE-2.0
011:
012: Unless required by applicable law or agreed to in writing, software
013: distributed under the License is distributed on an "AS IS" BASIS,
014: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: See the License for the specific language governing permissions and
016: limitations under the License.
017:
018: */
019: package org.apache.batik.dom.events;
020:
021: import org.w3c.dom.views.AbstractView;
022:
023: /**
024: * The <code>KeyEvent</code> interface provides specific contextual
025: * information associated with Key events.
026: *
027: * @author <a href="mailto:tkormann@ilog.fr">Thierry Kormann</a>
028: * @version $Id: DOMKeyEvent.java 475477 2006-11-15 22:44:28Z cam $
029: * @since DOM Level 2 (Working Draft)
030: */
031: public class DOMKeyEvent extends DOMUIEvent {
032:
033: // VirtualKeyCode
034: public static final int CHAR_UNDEFINED = 0x0FFFF;
035: public static final int DOM_VK_0 = 0x30;
036: public static final int DOM_VK_1 = 0x31;
037: public static final int DOM_VK_2 = 0x32;
038: public static final int DOM_VK_3 = 0x33;
039: public static final int DOM_VK_4 = 0x34;
040: public static final int DOM_VK_5 = 0x35;
041: public static final int DOM_VK_6 = 0x36;
042: public static final int DOM_VK_7 = 0x37;
043: public static final int DOM_VK_8 = 0x38;
044: public static final int DOM_VK_9 = 0x39;
045: public static final int DOM_VK_A = 0x41;
046: public static final int DOM_VK_ACCEPT = 0x1E;
047: public static final int DOM_VK_ADD = 0x6B;
048: public static final int DOM_VK_AGAIN = 0xFFC9;
049: public static final int DOM_VK_ALL_CANDIDATES = 0x0100;
050: public static final int DOM_VK_ALPHANUMERIC = 0x00F0;
051: public static final int DOM_VK_ALT = 0x12;
052: public static final int DOM_VK_ALT_GRAPH = 0xFF7E;
053: public static final int DOM_VK_AMPERSAND = 0x96;
054: public static final int DOM_VK_ASTERISK = 0x97;
055: public static final int DOM_VK_AT = 0x0200;
056: public static final int DOM_VK_B = 0x42;
057: public static final int DOM_VK_BACK_QUOTE = 0xC0;
058: public static final int DOM_VK_BACK_SLASH = 0x5C;
059: public static final int DOM_VK_BACK_SPACE = 0x08;
060: public static final int DOM_VK_BRACELEFT = 0xA1;
061: public static final int DOM_VK_BRACERIGHT = 0xA2;
062: public static final int DOM_VK_C = 0x43;
063: public static final int DOM_VK_CANCEL = 0x03;
064: public static final int DOM_VK_CAPS_LOCK = 0x14;
065: public static final int DOM_VK_CIRCUMFLEX = 0x0202;
066: public static final int DOM_VK_CLEAR = 0x0C;
067: public static final int DOM_VK_CLOSE_BRACKET = 0x5D;
068: public static final int DOM_VK_CODE_INPUT = 0x0102;
069: public static final int DOM_VK_COLON = 0x0201;
070: public static final int DOM_VK_COMMA = 0x2C;
071: public static final int DOM_VK_COMPOSE = 0xFF20;
072: public static final int DOM_VK_CONTROL = 0x11;
073: public static final int DOM_VK_CONVERT = 0x1C;
074: public static final int DOM_VK_COPY = 0xFFCD;
075: public static final int DOM_VK_CUT = 0xFFD1;
076: public static final int DOM_VK_D = 0x44;
077: public static final int DOM_VK_DEAD_ABOVEDOT = 0x86;
078: public static final int DOM_VK_DEAD_ABOVERING = 0x88;
079: public static final int DOM_VK_DEAD_ACUTE = 0x81;
080: public static final int DOM_VK_DEAD_BREVE = 0x85;
081: public static final int DOM_VK_DEAD_CARON = 0x8A;
082: public static final int DOM_VK_DEAD_CEDILLA = 0x8B;
083: public static final int DOM_VK_DEAD_CIRCUMFLEX = 0x82;
084: public static final int DOM_VK_DEAD_DIAERESIS = 0x87;
085: public static final int DOM_VK_DEAD_DOUBLEACUTE = 0x89;
086: public static final int DOM_VK_DEAD_GRAVE = 0x80;
087: public static final int DOM_VK_DEAD_IOTA = 0x8D;
088: public static final int DOM_VK_DEAD_MACRON = 0x84;
089: public static final int DOM_VK_DEAD_OGONEK = 0x8C;
090: public static final int DOM_VK_DEAD_SEMIVOICED_SOUND = 0x8F;
091: public static final int DOM_VK_DEAD_TILDE = 0x83;
092: public static final int DOM_VK_DEAD_VOICED_SOUND = 0x8E;
093: public static final int DOM_VK_DECIMAL = 0x6E;
094: public static final int DOM_VK_DELETE = 0x7F;
095: public static final int DOM_VK_DIVIDE = 0x6F;
096: public static final int DOM_VK_DOLLAR = 0x0203;
097: public static final int DOM_VK_DOWN = 0x28;
098: public static final int DOM_VK_E = 0x45;
099: public static final int DOM_VK_END = 0x23;
100: public static final int DOM_VK_ENTER = 0x0D;
101: public static final int DOM_VK_EQUALS = 0x3D;
102: public static final int DOM_VK_ESCAPE = 0x1B;
103: public static final int DOM_VK_EURO_SIGN = 0x0204;
104: public static final int DOM_VK_EXCLAMATION_MARK = 0x0205;
105: public static final int DOM_VK_F = 0x46;
106: public static final int DOM_VK_F1 = 0x70;
107: public static final int DOM_VK_F10 = 0x79;
108: public static final int DOM_VK_F11 = 0x7A;
109: public static final int DOM_VK_F12 = 0x7B;
110: public static final int DOM_VK_F13 = 0xF000;
111: public static final int DOM_VK_F14 = 0xF001;
112: public static final int DOM_VK_F15 = 0xF002;
113: public static final int DOM_VK_F16 = 0xF003;
114: public static final int DOM_VK_F17 = 0xF004;
115: public static final int DOM_VK_F18 = 0xF005;
116: public static final int DOM_VK_F19 = 0xF006;
117: public static final int DOM_VK_F2 = 0x71;
118: public static final int DOM_VK_F20 = 0xF007;
119: public static final int DOM_VK_F21 = 0xF008;
120: public static final int DOM_VK_F22 = 0xF009;
121: public static final int DOM_VK_F23 = 0xF00A;
122: public static final int DOM_VK_F24 = 0xF00B;
123: public static final int DOM_VK_F3 = 0x72;
124: public static final int DOM_VK_F4 = 0x73;
125: public static final int DOM_VK_F5 = 0x74;
126: public static final int DOM_VK_F6 = 0x75;
127: public static final int DOM_VK_F7 = 0x76;
128: public static final int DOM_VK_F8 = 0x77;
129: public static final int DOM_VK_F9 = 0x78;
130: public static final int DOM_VK_FINAL = 0x18;
131: public static final int DOM_VK_FIND = 0xFFD0;
132: public static final int DOM_VK_FULL_WIDTH = 0x00F3;
133: public static final int DOM_VK_G = 0x47;
134: public static final int DOM_VK_GREATER = 0xA0;
135: public static final int DOM_VK_H = 0x48;
136: public static final int DOM_VK_HALF_WIDTH = 0x00F4;
137: public static final int DOM_VK_HELP = 0x9C;
138: public static final int DOM_VK_HIRAGANA = 0x00F2;
139: public static final int DOM_VK_HOME = 0x24;
140: public static final int DOM_VK_I = 0x49;
141: public static final int DOM_VK_INSERT = 0x9B;
142: public static final int DOM_VK_INVERTED_EXCLAMATION_MARK = 0x0206;
143: public static final int DOM_VK_J = 0x4A;
144: public static final int DOM_VK_JAPANESE_HIRAGANA = 0x0104;
145: public static final int DOM_VK_JAPANESE_KATAKANA = 0x0103;
146: public static final int DOM_VK_JAPANESE_ROMAN = 0x0105;
147: public static final int DOM_VK_K = 0x4B;
148: public static final int DOM_VK_KANA = 0x15;
149: public static final int DOM_VK_KANJI = 0x19;
150: public static final int DOM_VK_KATAKANA = 0x00F1;
151: public static final int DOM_VK_KP_DOWN = 0xE1;
152: public static final int DOM_VK_KP_LEFT = 0xE2;
153: public static final int DOM_VK_KP_RIGHT = 0xE3;
154: public static final int DOM_VK_KP_UP = 0xE0;
155: public static final int DOM_VK_L = 0x4C;
156: public static final int DOM_VK_LEFT = 0x25;
157: public static final int DOM_VK_LEFT_PARENTHESIS = 0x0207;
158: public static final int DOM_VK_LESS = 0x99;
159: public static final int DOM_VK_M = 0x4D;
160: public static final int DOM_VK_META = 0x9D;
161: public static final int DOM_VK_MINUS = 0x2D;
162: public static final int DOM_VK_MODECHANGE = 0x1F;
163: public static final int DOM_VK_MULTIPLY = 0x6A;
164: public static final int DOM_VK_N = 0x4E;
165: public static final int DOM_VK_NONCONVERT = 0x1D;
166: public static final int DOM_VK_NUM_LOCK = 0x90;
167: public static final int DOM_VK_NUMBER_SIGN = 0x0208;
168: public static final int DOM_VK_NUMPAD0 = 0x60;
169: public static final int DOM_VK_NUMPAD1 = 0x61;
170: public static final int DOM_VK_NUMPAD2 = 0x62;
171: public static final int DOM_VK_NUMPAD3 = 0x63;
172: public static final int DOM_VK_NUMPAD4 = 0x64;
173: public static final int DOM_VK_NUMPAD5 = 0x65;
174: public static final int DOM_VK_NUMPAD6 = 0x66;
175: public static final int DOM_VK_NUMPAD7 = 0x67;
176: public static final int DOM_VK_NUMPAD8 = 0x68;
177: public static final int DOM_VK_NUMPAD9 = 0x69;
178: public static final int DOM_VK_O = 0x4F;
179: public static final int DOM_VK_OPEN_BRACKET = 0x5B;
180: public static final int DOM_VK_P = 0x50;
181: public static final int DOM_VK_PAGE_DOWN = 0x22;
182: public static final int DOM_VK_PAGE_UP = 0x21;
183: public static final int DOM_VK_PASTE = 0xFFCF;
184: public static final int DOM_VK_PAUSE = 0x13;
185: public static final int DOM_VK_PERIOD = 0x2E;
186: public static final int DOM_VK_PLUS = 0x0209;
187: public static final int DOM_VK_PREVIOUS_CANDIDATE = 0x0101;
188: public static final int DOM_VK_PRINTSCREEN = 0x9A;
189: public static final int DOM_VK_PROPS = 0xFFCA;
190: public static final int DOM_VK_Q = 0x51;
191: public static final int DOM_VK_QUOTE = 0xDE;
192: public static final int DOM_VK_QUOTEDBL = 0x98;
193: public static final int DOM_VK_R = 0x52;
194: public static final int DOM_VK_RIGHT = 0x27;
195: public static final int DOM_VK_RIGHT_PARENTHESIS = 0x020A;
196: public static final int DOM_VK_ROMAN_CHARACTERS = 0x00F5;
197: public static final int DOM_VK_S = 0x53;
198: public static final int DOM_VK_SCROLL_LOCK = 0x91;
199: public static final int DOM_VK_SEMICOLON = 0x3B;
200: public static final int DOM_VK_SEPARATER = 0x6C;
201: public static final int DOM_VK_SHIFT = 0x10;
202: public static final int DOM_VK_SLASH = 0x2F;
203: public static final int DOM_VK_SPACE = 0x20;
204: public static final int DOM_VK_STOP = 0xFFC8;
205: public static final int DOM_VK_SUBTRACT = 0x6D;
206: public static final int DOM_VK_T = 0x54;
207: public static final int DOM_VK_TAB = 0x09;
208: public static final int DOM_VK_U = 0x55;
209: public static final int DOM_VK_UNDEFINED = 0x0;
210: public static final int DOM_VK_UNDERSCORE = 0x020B;
211: public static final int DOM_VK_UNDO = 0xFFCB;
212: public static final int DOM_VK_UP = 0x26;
213: public static final int DOM_VK_V = 0x56;
214: public static final int DOM_VK_W = 0x57;
215: public static final int DOM_VK_X = 0x58;
216: public static final int DOM_VK_Y = 0x59;
217: public static final int DOM_VK_Z = 0x5A;
218:
219: protected boolean ctrlKey;
220: protected boolean altKey;
221: protected boolean shiftKey;
222: protected boolean metaKey;
223: protected int keyCode;
224: protected int charCode;
225:
226: /**
227: * Returns whether the 'ctrl' key was depressed during the firing of the
228: * event.
229: */
230: public boolean getCtrlKey() {
231: return ctrlKey;
232: }
233:
234: /**
235: * Returns whether the 'shift' key was depressed during the firing of the
236: * event.
237: */
238: public boolean getShiftKey() {
239: return shiftKey;
240: }
241:
242: /**
243: * Returns whether the 'alt' key was depressed during the firing of the
244: * event. On some platforms this key may map to an alternative key name.
245: */
246: public boolean getAltKey() {
247: return altKey;
248: }
249:
250: /**
251: * Returns whether the 'meta' key was depressed during the firing of
252: * the event. On some platforms this key may map to an alternative
253: * key name.
254: */
255: public boolean getMetaKey() {
256: return metaKey;
257: }
258:
259: /**
260: * Returns the virtual key code value of the key which was depressed
261: * if the event is a key event. Otherwise, the value returned is zero.
262: */
263: public int getKeyCode() {
264: return keyCode;
265: }
266:
267: /**
268: * Returns the value of the Unicode character associated with the
269: * depressed key if the event is a key event. Otherwise, the value
270: * returned is zero.
271: */
272: public int getCharCode() {
273: return charCode;
274: }
275:
276: /**
277: * Initializes this KeyEvent.
278: * @param typeArg Specifies the event type.
279: * @param canBubbleArg Specifies whether or not the event can bubble.
280: * @param cancelableArg Specifies whether or not the event's default action
281: * can be prevent.
282: * @param ctrlKeyArg Specifies whether or not control key was depressed
283: * during the <code>Event</code>.
284: * @param altKeyArg Specifies whether or not alt key was depressed during
285: * the <code>Event</code>.
286: * @param shiftKeyArg Specifies whether or not shift key was depressed
287: * during the <code>Event</code>.
288: * @param metaKeyArg Specifies whether or not meta key was depressed during
289: * the <code>Event</code>.
290: * @param keyCodeArg Specifies the <code>Event</code>'s <code>keyCode</code>
291: * @param charCodeArg Specifies the <code>Event</code>'s
292: * <code>charCode</code>
293: * @param viewArg Specifies the <code>Event</code>'s
294: * <code>AbstractView</code>.
295: */
296: public void initKeyEvent(String typeArg, boolean canBubbleArg,
297: boolean cancelableArg, boolean ctrlKeyArg,
298: boolean altKeyArg, boolean shiftKeyArg, boolean metaKeyArg,
299: int keyCodeArg, int charCodeArg, AbstractView viewArg) {
300: initUIEvent(typeArg, canBubbleArg, cancelableArg, viewArg, 0);
301: ctrlKey = ctrlKeyArg;
302: altKey = altKeyArg;
303: shiftKey = shiftKeyArg;
304: metaKey = metaKeyArg;
305: keyCode = keyCodeArg;
306: charCode = charCodeArg;
307: }
308: }
|