1:
37:
38:
39: package ;
40:
41: import ;
42: import ;
43:
44: import ;
45: import ;
46: import ;
47:
48:
81: public class KeyEvent extends InputEvent
82: {
83:
86: private static final long serialVersionUID = -2352130953028126954L;
87:
88:
89: public static final int KEY_FIRST = 400;
90:
91:
92: public static final int KEY_LAST = 402;
93:
94:
100: public static final int KEY_TYPED = 400;
101:
102:
103: public static final int KEY_PRESSED = 401;
104:
105:
106: public static final int KEY_RELEASED = 402;
107:
108:
109: public static final int VK_ENTER = '\n';
110:
111:
112: public static final int VK_BACK_SPACE = '\b';
113:
114:
115: public static final int VK_TAB = '\t';
116:
117:
118: public static final int VK_CANCEL = 3;
119:
120:
121: public static final int VK_CLEAR = 12;
122:
123:
124: public static final int VK_SHIFT = 16;
125:
126:
127: public static final int VK_CONTROL = 17;
128:
129:
130: public static final int VK_ALT = 18;
131:
132:
133: public static final int VK_PAUSE = 19;
134:
135:
136: public static final int VK_CAPS_LOCK = 20;
137:
138:
139: public static final int VK_ESCAPE = 27;
140:
141:
142: public static final int VK_SPACE = ' ';
143:
144:
145: public static final int VK_PAGE_UP = 33;
146:
147:
148: public static final int VK_PAGE_DOWN = 34;
149:
150:
151: public static final int VK_END = 35;
152:
153:
154: public static final int VK_HOME = 36;
155:
156:
161: public static final int VK_LEFT = 37;
162:
163:
168: public static final int VK_UP = 38;
169:
170:
175: public static final int VK_RIGHT = 39;
176:
177:
182: public static final int VK_DOWN = 40;
183:
184:
185: public static final int VK_COMMA = ',';
186:
187:
192: public static final int VK_MINUS = '-';
193:
194:
195: public static final int VK_PERIOD = '.';
196:
197:
198: public static final int VK_SLASH = '/';
199:
200:
201: public static final int VK_0 = '0';
202:
203:
204: public static final int VK_1 = '1';
205:
206:
207: public static final int VK_2 = '2';
208:
209:
210: public static final int VK_3 = '3';
211:
212:
213: public static final int VK_4 = '4';
214:
215:
216: public static final int VK_5 = '5';
217:
218:
219: public static final int VK_6 = '6';
220:
221:
222: public static final int VK_7 = '7';
223:
224:
225: public static final int VK_8 = '8';
226:
227:
228: public static final int VK_9 = '9';
229:
230:
231: public static final int VK_SEMICOLON = ';';
232:
233:
234: public static final int VK_EQUALS = '=';
235:
236:
237: public static final int VK_A = 'A';
238:
239:
240: public static final int VK_B = 'B';
241:
242:
243: public static final int VK_C = 'C';
244:
245:
246: public static final int VK_D = 'D';
247:
248:
249: public static final int VK_E = 'E';
250:
251:
252: public static final int VK_F = 'F';
253:
254:
255: public static final int VK_G = 'G';
256:
257:
258: public static final int VK_H = 'H';
259:
260:
261: public static final int VK_I = 'I';
262:
263:
264: public static final int VK_J = 'J';
265:
266:
267: public static final int VK_K = 'K';
268:
269:
270: public static final int VK_L = 'L';
271:
272:
273: public static final int VK_M = 'M';
274:
275:
276: public static final int VK_N = 'N';
277:
278:
279: public static final int VK_O = 'O';
280:
281:
282: public static final int VK_P = 'P';
283:
284:
285: public static final int VK_Q = 'Q';
286:
287:
288: public static final int VK_R = 'R';
289:
290:
291: public static final int VK_S = 'S';
292:
293:
294: public static final int VK_T = 'T';
295:
296:
297: public static final int VK_U = 'U';
298:
299:
300: public static final int VK_V = 'V';
301:
302:
303: public static final int VK_W = 'W';
304:
305:
306: public static final int VK_X = 'X';
307:
308:
309: public static final int VK_Y = 'Y';
310:
311:
312: public static final int VK_Z = 'Z';
313:
314:
315: public static final int VK_OPEN_BRACKET = '[';
316:
317:
318: public static final int VK_BACK_SLASH = '\\';
319:
320:
321: public static final int VK_CLOSE_BRACKET = ']';
322:
323:
324: public static final int VK_NUMPAD0 = 96;
325:
326:
327: public static final int VK_NUMPAD1 = 97;
328:
329:
330: public static final int VK_NUMPAD2 = 98;
331:
332:
333: public static final int VK_NUMPAD3 = 99;
334:
335:
336: public static final int VK_NUMPAD4 = 100;
337:
338:
339: public static final int VK_NUMPAD5 = 101;
340:
341:
342: public static final int VK_NUMPAD6 = 102;
343:
344:
345: public static final int VK_NUMPAD7 = 103;
346:
347:
348: public static final int VK_NUMPAD8 = 104;
349:
350:
351: public static final int VK_NUMPAD9 = 105;
352:
353:
354: public static final int VK_MULTIPLY = 106;
355:
356:
357: public static final int VK_ADD = 107;
358:
359:
365: public static final int VK_SEPARATER = 108;
366:
367:
372: public static final int VK_SEPARATOR = 108;
373:
374:
375: public static final int VK_SUBTRACT = 109;
376:
377:
378: public static final int VK_DECIMAL = 110;
379:
380:
381: public static final int VK_DIVIDE = 111;
382:
383:
384: public static final int VK_DELETE = 127;
385:
386:
387: public static final int VK_NUM_LOCK = 144;
388:
389:
390: public static final int VK_SCROLL_LOCK = 145;
391:
392:
393: public static final int VK_F1 = 112;
394:
395:
396: public static final int VK_F2 = 113;
397:
398:
399: public static final int VK_F3 = 114;
400:
401:
402: public static final int VK_F4 = 115;
403:
404:
405: public static final int VK_F5 = 116;
406:
407:
408: public static final int VK_F6 = 117;
409:
410:
411: public static final int VK_F7 = 118;
412:
413:
414: public static final int VK_F8 = 119;
415:
416:
417: public static final int VK_F9 = 120;
418:
419:
420: public static final int VK_F10 = 121;
421:
422:
423: public static final int VK_F11 = 122;
424:
425:
426: public static final int VK_F12 = 123;
427:
428:
433: public static final int VK_F13 = 61440;
434:
435:
440: public static final int VK_F14 = 61441;
441:
442:
447: public static final int VK_F15 = 61442;
448:
449:
454: public static final int VK_F16 = 61443;
455:
456:
461: public static final int VK_F17 = 61444;
462:
463:
468: public static final int VK_F18 = 61445;
469:
470:
475: public static final int VK_F19 = 61446;
476:
477:
482: public static final int VK_F20 = 61447;
483:
484:
489: public static final int VK_F21 = 61448;
490:
491:
496: public static final int VK_F22 = 61449;
497:
498:
503: public static final int VK_F23 = 61450;
504:
505:
510: public static final int VK_F24 = 61451;
511:
512:
513: public static final int VK_PRINTSCREEN = 154;
514:
515:
516: public static final int VK_INSERT = 155;
517:
518:
519: public static final int VK_HELP = 156;
520:
521:
522: public static final int VK_META = 157;
523:
524:
525: public static final int VK_BACK_QUOTE = 192;
526:
527:
528: public static final int VK_QUOTE = 222;
529:
530:
536: public static final int VK_KP_UP = 224;
537:
538:
544: public static final int VK_KP_DOWN = 225;
545:
546:
552: public static final int VK_KP_LEFT = 226;
553:
554:
560: public static final int VK_KP_RIGHT = 227;
561:
562:
567: public static final int VK_DEAD_GRAVE = 128;
568:
569:
574: public static final int VK_DEAD_ACUTE = 129;
575:
576:
581: public static final int VK_DEAD_CIRCUMFLEX = 130;
582:
583:
588: public static final int VK_DEAD_TILDE = 131;
589:
590:
595: public static final int VK_DEAD_MACRON = 132;
596:
597:
602: public static final int VK_DEAD_BREVE = 133;
603:
604:
609: public static final int VK_DEAD_ABOVEDOT = 134;
610:
611:
616: public static final int VK_DEAD_DIAERESIS = 135;
617:
618:
623: public static final int VK_DEAD_ABOVERING = 136;
624:
625:
630: public static final int VK_DEAD_DOUBLEACUTE = 137;
631:
632:
637: public static final int VK_DEAD_CARON = 138;
638:
639:
644: public static final int VK_DEAD_CEDILLA = 139;
645:
646:
651: public static final int VK_DEAD_OGONEK = 140;
652:
653:
658: public static final int VK_DEAD_IOTA = 141;
659:
660:
665: public static final int VK_DEAD_VOICED_SOUND = 142;
666:
667:
672: public static final int VK_DEAD_SEMIVOICED_SOUND = 143;
673:
674:
679: public static final int VK_AMPERSAND = 150;
680:
681:
686: public static final int VK_ASTERISK = 151;
687:
688:
693: public static final int VK_QUOTEDBL = 152;
694:
695:
700: public static final int VK_LESS = 153;
701:
702:
707: public static final int VK_GREATER = 160;
708:
709:
714: public static final int VK_BRACELEFT = 161;
715:
716:
721: public static final int VK_BRACERIGHT = 162;
722:
723:
728: public static final int VK_AT = 512;
729:
730:
735: public static final int VK_COLON = 513;
736:
737:
742: public static final int VK_CIRCUMFLEX = 514;
743:
744:
749: public static final int VK_DOLLAR = 515;
750:
751:
756: public static final int VK_EURO_SIGN = 516;
757:
758:
763: public static final int VK_EXCLAMATION_MARK = 517;
764:
765:
770: public static final int VK_INVERTED_EXCLAMATION_MARK = 518;
771:
772:
777: public static final int VK_LEFT_PARENTHESIS = 519;
778:
779:
784: public static final int VK_NUMBER_SIGN = 520;
785:
786:
791: public static final int VK_PLUS = 521;
792:
793:
798: public static final int VK_RIGHT_PARENTHESIS = 522;
799:
800:
805: public static final int VK_UNDERSCORE = 523;
806:
807:
808: public static final int VK_FINAL = 24;
809:
810:
811: public static final int VK_CONVERT = 28;
812:
813:
814: public static final int VK_NONCONVERT = 29;
815:
816:
817: public static final int VK_ACCEPT = 30;
818:
819:
820: public static final int VK_MODECHANGE = 31;
821:
822:
823: public static final int VK_KANA = 21;
824:
825:
826: public static final int VK_KANJI = 25;
827:
828:
833: public static final int VK_ALPHANUMERIC = 240;
834:
835:
840: public static final int VK_KATAKANA = 241;
841:
842:
847: public static final int VK_HIRAGANA = 242;
848:
849:
854: public static final int VK_FULL_WIDTH = 243;
855:
856:
861: public static final int VK_HALF_WIDTH = 244;
862:
863:
868: public static final int VK_ROMAN_CHARACTERS = 245;
869:
870:
875: public static final int VK_ALL_CANDIDATES = 256;
876:
877:
882: public static final int VK_PREVIOUS_CANDIDATE = 257;
883:
884:
889: public static final int VK_CODE_INPUT = 258;
890:
891:
896: public static final int VK_JAPANESE_KATAKANA = 259;
897:
898:
903: public static final int VK_JAPANESE_HIRAGANA = 260;
904:
905:
910: public static final int VK_JAPANESE_ROMAN = 261;
911:
912:
917: public static final int VK_KANA_LOCK = 262;
918:
919:
924: public static final int VK_INPUT_METHOD_ON_OFF = 263;
925:
926:
931: public static final int VK_CUT = 65489;
932:
933:
938: public static final int VK_COPY = 65485;
939:
940:
945: public static final int VK_PASTE = 65487;
946:
947:
952: public static final int VK_UNDO = 65483;
953:
954:
959: public static final int VK_AGAIN = 65481;
960:
961:
966: public static final int VK_FIND = 65488;
967:
968:
973: public static final int VK_PROPS = 65482;
974:
975:
980: public static final int VK_STOP = 65480;
981:
982:
987: public static final int VK_COMPOSE = 65312;
988:
989:
994: public static final int VK_ALT_GRAPH = 65406;
995:
996:
1001: public static final int VK_BEGIN = 65368;
1002:
1003:
1008: public static final int VK_CONTEXT_MENU = 525;
1009:
1010:
1015: public static final int VK_WINDOWS = 524;
1016:
1017:
1021: public static final int VK_UNDEFINED = 0;
1022:
1023:
1027: public static final char CHAR_UNDEFINED = '\uffff';
1028:
1029:
1035: public static final int KEY_LOCATION_UNKNOWN = 0;
1036:
1037:
1043: public static final int KEY_LOCATION_STANDARD = 1;
1044:
1045:
1051: public static final int KEY_LOCATION_LEFT = 2;
1052:
1053:
1059: public static final int KEY_LOCATION_RIGHT = 3;
1060:
1061:
1066: public static final int KEY_LOCATION_NUMPAD = 4;
1067:
1068:
1075: private int keyCode;
1076:
1077:
1084: private char keyChar;
1085:
1086:
1095: private final int keyLocation;
1096:
1097:
1105: private boolean isProxyActive;
1106:
1107:
1108:
1123: public KeyEvent(Component source, int id, long when, int modifiers,
1124: int keyCode, char keyChar, int keyLocation)
1125: {
1126: super(source, id, when, modifiers);
1127: this.keyCode = keyCode;
1128: this.keyChar = keyChar;
1129: this.keyLocation = keyLocation;
1130: if ((id == KEY_TYPED && (keyCode != VK_UNDEFINED
1131: || keyChar == CHAR_UNDEFINED))
1132: || keyLocation < KEY_LOCATION_UNKNOWN
1133: || keyLocation > KEY_LOCATION_NUMPAD)
1134: throw new IllegalArgumentException();
1135: }
1136:
1137:
1151: public KeyEvent(Component source, int id, long when, int modifiers,
1152: int keyCode, char keyChar)
1153: {
1154: this(source, id, when, modifiers, keyCode, keyChar, KEY_LOCATION_UNKNOWN);
1155: }
1156:
1157:
1171: public KeyEvent(Component source, int id, long when, int modifiers,
1172: int keyCode)
1173: {
1174: this(source, id, when, modifiers, keyCode, '\0', KEY_LOCATION_UNKNOWN);
1175: }
1176:
1177:
1184: public int getKeyCode()
1185: {
1186: return keyCode;
1187: }
1188:
1189:
1195: public void setKeyCode(int keyCode)
1196: {
1197: this.keyCode = keyCode;
1198: }
1199:
1200:
1207: public char getKeyChar()
1208: {
1209: return keyChar;
1210: }
1211:
1212:
1217: public void setKeyChar(char keyChar)
1218: {
1219: this.keyChar = keyChar;
1220: }
1221:
1222:
1233: public void setModifiers(int modifiers)
1234: {
1235: this.modifiers = EventModifier.extend(modifiers);
1236: }
1237:
1238:
1249: public int getKeyLocation()
1250: {
1251: return keyLocation;
1252: }
1253:
1254:
1262: public static String getKeyText(int keyCode)
1263: {
1264: switch (keyCode)
1265: {
1266: case VK_CANCEL:
1267: return "Cancel";
1268: case VK_BACK_SPACE:
1269: return "Backspace";
1270: case VK_TAB:
1271: return "Tab";
1272: case VK_ENTER:
1273: return "Enter";
1274: case VK_CLEAR:
1275: return "Clear";
1276: case VK_SHIFT:
1277: return "Shift";
1278: case VK_CONTROL:
1279: return "Ctrl";
1280: case VK_ALT:
1281: return "Alt";
1282: case VK_PAUSE:
1283: return "Pause";
1284: case VK_CAPS_LOCK:
1285: return "Caps Lock";
1286: case VK_KANA:
1287: return "Kana";
1288: case VK_FINAL:
1289: return "Final";
1290: case VK_KANJI:
1291: return "Kanji";
1292: case VK_ESCAPE:
1293: return "Escape";
1294: case VK_CONVERT:
1295: return "Convert";
1296: case VK_NONCONVERT:
1297: return "No Convert";
1298: case VK_ACCEPT:
1299: return "Accept";
1300: case VK_MODECHANGE:
1301: return "Mode Change";
1302: case VK_SPACE:
1303: return "Space";
1304: case VK_PAGE_UP:
1305: return "Page Up";
1306: case VK_PAGE_DOWN:
1307: return "Page Down";
1308: case VK_END:
1309: return "End";
1310: case VK_HOME:
1311: return "Home";
1312: case VK_LEFT:
1313: case VK_KP_LEFT:
1314: return "Left";
1315: case VK_UP:
1316: case VK_KP_UP:
1317: return "Up";
1318: case VK_RIGHT:
1319: case VK_KP_RIGHT:
1320: return "Right";
1321: case VK_DOWN:
1322: case VK_KP_DOWN:
1323: return "Down";
1324: case VK_MINUS:
1325: return "Minus";
1326: case VK_MULTIPLY:
1327: return "NumPad *";
1328: case VK_ADD:
1329: return "NumPad +";
1330: case VK_SEPARATOR:
1331: return "NumPad ,";
1332: case VK_SUBTRACT:
1333: return "NumPad -";
1334: case VK_DECIMAL:
1335: return "NumPad .";
1336: case VK_DIVIDE:
1337: return "NumPad /";
1338: case VK_DELETE:
1339: return "Delete";
1340: case VK_DEAD_GRAVE:
1341: return "Dead Grave";
1342: case VK_DEAD_ACUTE:
1343: return "Dead Acute";
1344: case VK_DEAD_CIRCUMFLEX:
1345: return "Dead Circumflex";
1346: case VK_DEAD_TILDE:
1347: return "Dead Tilde";
1348: case VK_DEAD_MACRON:
1349: return "Dead Macron";
1350: case VK_DEAD_BREVE:
1351: return "Dead Breve";
1352: case VK_DEAD_ABOVEDOT:
1353: return "Dead Above Dot";
1354: case VK_DEAD_DIAERESIS:
1355: return "Dead Diaeresis";
1356: case VK_DEAD_ABOVERING:
1357: return "Dead Above Ring";
1358: case VK_DEAD_DOUBLEACUTE:
1359: return "Dead Double Acute";
1360: case VK_DEAD_CARON:
1361: return "Dead Caron";
1362: case VK_DEAD_CEDILLA:
1363: return "Dead Cedilla";
1364: case VK_DEAD_OGONEK:
1365: return "Dead Ogonek";
1366: case VK_DEAD_IOTA:
1367: return "Dead Iota";
1368: case VK_DEAD_VOICED_SOUND:
1369: return "Dead Voiced Sound";
1370: case VK_DEAD_SEMIVOICED_SOUND:
1371: return "Dead Semivoiced Sound";
1372: case VK_NUM_LOCK:
1373: return "Num Lock";
1374: case VK_SCROLL_LOCK:
1375: return "Scroll Lock";
1376: case VK_AMPERSAND:
1377: return "Ampersand";
1378: case VK_ASTERISK:
1379: return "Asterisk";
1380: case VK_QUOTEDBL:
1381: return "Double Quote";
1382: case VK_LESS:
1383: return "Less";
1384: case VK_PRINTSCREEN:
1385: return "Print Screen";
1386: case VK_INSERT:
1387: return "Insert";
1388: case VK_HELP:
1389: return "Help";
1390: case VK_META:
1391: return "Meta";
1392: case VK_GREATER:
1393: return "Greater";
1394: case VK_BRACELEFT:
1395: return "Left Brace";
1396: case VK_BRACERIGHT:
1397: return "Right Brace";
1398: case VK_BACK_QUOTE:
1399: return "Back Quote";
1400: case VK_QUOTE:
1401: return "Quote";
1402: case VK_ALPHANUMERIC:
1403: return "Alphanumeric";
1404: case VK_KATAKANA:
1405: return "Katakana";
1406: case VK_HIRAGANA:
1407: return "Hiragana";
1408: case VK_FULL_WIDTH:
1409: return "Full-Width";
1410: case VK_HALF_WIDTH:
1411: return "Half-Width";
1412: case VK_ROMAN_CHARACTERS:
1413: return "Roman Characters";
1414: case VK_ALL_CANDIDATES:
1415: return "All Candidates";
1416: case VK_PREVIOUS_CANDIDATE:
1417: return "Previous Candidate";
1418: case VK_CODE_INPUT:
1419: return "Code Input";
1420: case VK_JAPANESE_KATAKANA:
1421: return "Japanese Katakana";
1422: case VK_JAPANESE_HIRAGANA:
1423: return "Japanese Hiragana";
1424: case VK_JAPANESE_ROMAN:
1425: return "Japanese Roman";
1426: case VK_KANA_LOCK:
1427: return "Kana Lock";
1428: case VK_INPUT_METHOD_ON_OFF:
1429: return "Input Method On/Off";
1430: case VK_AT:
1431: return "At";
1432: case VK_COLON:
1433: return "Colon";
1434: case VK_CIRCUMFLEX:
1435: return "Circumflex";
1436: case VK_DOLLAR:
1437: return "Dollar";
1438: case VK_EURO_SIGN:
1439: return "Euro";
1440: case VK_EXCLAMATION_MARK:
1441: return "Exclamation Mark";
1442: case VK_INVERTED_EXCLAMATION_MARK:
1443: return "Inverted Exclamation Mark";
1444: case VK_LEFT_PARENTHESIS:
1445: return "Left Parenthesis";
1446: case VK_NUMBER_SIGN:
1447: return "Number Sign";
1448: case VK_PLUS:
1449: return "Plus";
1450: case VK_RIGHT_PARENTHESIS:
1451: return "Right Parenthesis";
1452: case VK_UNDERSCORE:
1453: return "Underscore";
1454: case VK_COMPOSE:
1455: return "Compose";
1456: case VK_ALT_GRAPH:
1457: return "Alt Graph";
1458: case VK_STOP:
1459: return "Stop";
1460: case VK_AGAIN:
1461: return "Again";
1462: case VK_PROPS:
1463: return "Props";
1464: case VK_UNDO:
1465: return "Undo";
1466: case VK_COPY:
1467: return "Copy";
1468: case VK_PASTE:
1469: return "Paste";
1470: case VK_FIND:
1471: return "Find";
1472: case VK_CUT:
1473: return "Cut";
1474: case VK_COMMA:
1475: case VK_PERIOD:
1476: case VK_SLASH:
1477: case VK_0:
1478: case VK_1:
1479: case VK_2:
1480: case VK_3:
1481: case VK_4:
1482: case VK_5:
1483: case VK_6:
1484: case VK_7:
1485: case VK_8:
1486: case VK_9:
1487: case VK_SEMICOLON:
1488: case VK_EQUALS:
1489: case VK_A:
1490: case VK_B:
1491: case VK_C:
1492: case VK_D:
1493: case VK_E:
1494: case VK_F:
1495: case VK_G:
1496: case VK_H:
1497: case VK_I:
1498: case VK_J:
1499: case VK_K:
1500: case VK_L:
1501: case VK_M:
1502: case VK_N:
1503: case VK_O:
1504: case VK_P:
1505: case VK_Q:
1506: case VK_R:
1507: case VK_S:
1508: case VK_T:
1509: case VK_U:
1510: case VK_V:
1511: case VK_W:
1512: case VK_X:
1513: case VK_Y:
1514: case VK_Z:
1515: case VK_OPEN_BRACKET:
1516: case VK_BACK_SLASH:
1517: case VK_CLOSE_BRACKET:
1518: return "" + (char) keyCode;
1519: case VK_NUMPAD0:
1520: case VK_NUMPAD1:
1521: case VK_NUMPAD2:
1522: case VK_NUMPAD3:
1523: case VK_NUMPAD4:
1524: case VK_NUMPAD5:
1525: case VK_NUMPAD6:
1526: case VK_NUMPAD7:
1527: case VK_NUMPAD8:
1528: case VK_NUMPAD9:
1529: return "NumPad-" + (keyCode - VK_NUMPAD0);
1530: case VK_F1:
1531: case VK_F2:
1532: case VK_F3:
1533: case VK_F4:
1534: case VK_F5:
1535: case VK_F6:
1536: case VK_F7:
1537: case VK_F8:
1538: case VK_F9:
1539: case VK_F10:
1540: case VK_F11:
1541: case VK_F12:
1542: return "F" + (keyCode - (VK_F1 - 1));
1543: case VK_F13:
1544: case VK_F14:
1545: case VK_F15:
1546: case VK_F16:
1547: case VK_F17:
1548: case VK_F18:
1549: case VK_F19:
1550: case VK_F20:
1551: case VK_F21:
1552: case VK_F22:
1553: case VK_F23:
1554: case VK_F24:
1555: return "F" + (keyCode - (VK_F13 - 13));
1556: default:
1557:
1558: return "Unknown keyCode: 0x" + (keyCode < 0 ? "-" : "")
1559: + Integer.toHexString(Math.abs(keyCode));
1560: }
1561: }
1562:
1563:
1573: public static String getKeyModifiersText(int modifiers)
1574: {
1575: return getModifiersExText(EventModifier.extend(modifiers
1576: & EventModifier.OLD_MASK));
1577: }
1578:
1579:
1585: public boolean isActionKey()
1586: {
1587: switch (keyCode)
1588: {
1589: case VK_PAUSE:
1590: case VK_CAPS_LOCK:
1591: case VK_KANA:
1592: case VK_FINAL:
1593: case VK_KANJI:
1594: case VK_CONVERT:
1595: case VK_NONCONVERT:
1596: case VK_ACCEPT:
1597: case VK_MODECHANGE:
1598: case VK_PAGE_UP:
1599: case VK_PAGE_DOWN:
1600: case VK_END:
1601: case VK_HOME:
1602: case VK_LEFT:
1603: case VK_UP:
1604: case VK_RIGHT:
1605: case VK_DOWN:
1606: case VK_F1:
1607: case VK_F2:
1608: case VK_F3:
1609: case VK_F4:
1610: case VK_F5:
1611: case VK_F6:
1612: case VK_F7:
1613: case VK_F8:
1614: case VK_F9:
1615: case VK_F10:
1616: case VK_F11:
1617: case VK_F12:
1618: case VK_NUM_LOCK:
1619: case VK_SCROLL_LOCK:
1620: case VK_PRINTSCREEN:
1621: case VK_INSERT:
1622: case VK_HELP:
1623: case VK_KP_UP:
1624: case VK_KP_DOWN:
1625: case VK_KP_LEFT:
1626: case VK_KP_RIGHT:
1627: case VK_ALPHANUMERIC:
1628: case VK_KATAKANA:
1629: case VK_HIRAGANA:
1630: case VK_FULL_WIDTH:
1631: case VK_HALF_WIDTH:
1632: case VK_ROMAN_CHARACTERS:
1633: case VK_ALL_CANDIDATES:
1634: case VK_PREVIOUS_CANDIDATE:
1635: case VK_CODE_INPUT:
1636: case VK_JAPANESE_KATAKANA:
1637: case VK_JAPANESE_HIRAGANA:
1638: case VK_JAPANESE_ROMAN:
1639: case VK_KANA_LOCK:
1640: case VK_INPUT_METHOD_ON_OFF:
1641: case VK_F13:
1642: case VK_F14:
1643: case VK_F15:
1644: case VK_F16:
1645: case VK_F17:
1646: case VK_F18:
1647: case VK_F19:
1648: case VK_F20:
1649: case VK_F21:
1650: case VK_F22:
1651: case VK_F23:
1652: case VK_F24:
1653: case VK_STOP:
1654: case VK_AGAIN:
1655: case VK_PROPS:
1656: case VK_UNDO:
1657: case VK_COPY:
1658: case VK_PASTE:
1659: case VK_FIND:
1660: case VK_CUT:
1661: return true;
1662: default:
1663: return false;
1664: }
1665: }
1666:
1667:
1675: public String paramString()
1676: {
1677: CPStringBuilder s = new CPStringBuilder();
1678:
1679: switch (id)
1680: {
1681: case KEY_PRESSED:
1682: s.append("KEY_PRESSED");
1683: break;
1684: case KEY_RELEASED:
1685: s.append("KEY_RELEASED");
1686: break;
1687: case KEY_TYPED:
1688: s.append("KEY_TYPED");
1689: break;
1690: default:
1691: s.append("unknown type");
1692: }
1693:
1694: s.append(",keyCode=").append(keyCode);
1695:
1696: s.append(",keyText=").append(getKeyText(keyCode));
1697:
1698: s.append(",keyChar=");
1699: if (isActionKey()
1700: || keyCode == VK_SHIFT
1701: || keyCode == VK_CONTROL
1702: || keyCode == VK_ALT)
1703: s.append("Undefined keyChar");
1704: else
1705: {
1706:
1710: if (keyChar == VK_BACK_SPACE
1711: || keyChar == VK_TAB
1712: || keyChar == VK_ENTER
1713: || keyChar == VK_ESCAPE
1714: || keyChar == VK_DELETE)
1715: s.append(getKeyText(keyChar));
1716: else
1717: s.append("'").append(keyChar).append("'");
1718: }
1719:
1720: if ((modifiers & CONVERT_MASK) != 0)
1721: s.append(",modifiers=").append(getModifiersExText(modifiers
1722: & CONVERT_MASK));
1723: if (modifiers != 0)
1724: s.append(",extModifiers=").append(getModifiersExText(modifiers));
1725:
1726: s.append(",keyLocation=KEY_LOCATION_");
1727: switch (keyLocation)
1728: {
1729: case KEY_LOCATION_UNKNOWN:
1730: s.append("UNKNOWN");
1731: break;
1732: case KEY_LOCATION_STANDARD:
1733: s.append("STANDARD");
1734: break;
1735: case KEY_LOCATION_LEFT:
1736: s.append("LEFT");
1737: break;
1738: case KEY_LOCATION_RIGHT:
1739: s.append("RIGHT");
1740: break;
1741: case KEY_LOCATION_NUMPAD:
1742: s.append("NUMPAD");
1743: }
1744:
1745: return s.toString();
1746: }
1747:
1748:
1756: private void readObject(ObjectInputStream s)
1757: throws IOException, ClassNotFoundException
1758: {
1759: s.defaultReadObject();
1760: modifiersEx = EventModifier.extend(modifiers) & EventModifier.NEW_MASK;
1761: }
1762: }