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