0
|
1
|
|
2 package src;
|
|
3
|
|
4 import java.awt.event.KeyEvent;
|
|
5 import java.awt.event.KeyListener;
|
|
6
|
|
7 class Actions implements KeyListener {
|
|
8 String cheat="";
|
|
9 char pressKey =' ';
|
|
10
|
|
11 public void Actions(){}
|
|
12 @Override
|
|
13 public void keyTyped(KeyEvent e) {
|
|
14 }
|
|
15
|
|
16 @Override
|
|
17 public void keyReleased(KeyEvent event) {
|
|
18 }
|
|
19
|
|
20 @Override
|
|
21 public void keyPressed(KeyEvent event) {
|
|
22
|
|
23 if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('a')) {
|
|
24 isThere('a');
|
|
25 }
|
|
26 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('w')) {
|
|
27 isThere('w');
|
|
28 }
|
|
29 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('e')) {
|
|
30 isThere('e');
|
|
31 }
|
|
32 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('r')) {
|
|
33 isThere('r');
|
|
34 }
|
|
35 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('t')) {
|
|
36 isThere('t');
|
|
37 }
|
|
38 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('y')) {
|
|
39 isThere('y');
|
|
40 }
|
|
41 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('u')) {
|
|
42 isThere('u');
|
|
43 }
|
|
44 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('i')) {
|
|
45 isThere('i');
|
|
46 }
|
|
47 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('o')) {
|
|
48 isThere('o');
|
|
49 }
|
|
50 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('p')) {
|
|
51 isThere('p');
|
|
52 }
|
|
53 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('s')) {
|
|
54 isThere('s');
|
|
55 }
|
|
56 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('d')) {
|
|
57 isThere('d');
|
|
58 }
|
|
59 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('f')) {
|
|
60 isThere('f');
|
|
61 }
|
|
62 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('g')) {
|
|
63 isThere('g');
|
|
64 }
|
|
65 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('h')) {
|
|
66 isThere('h');
|
|
67 }
|
|
68 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('j')) {
|
|
69 isThere('j');
|
|
70 }
|
|
71 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('k')) {
|
|
72 isThere('k');
|
|
73 }
|
|
74 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('l')) {
|
|
75 isThere('l');
|
|
76 }
|
|
77 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('z')) {
|
|
78 isThere('z');
|
|
79 }
|
|
80 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('c')) {
|
|
81 isThere('c');
|
|
82 }
|
|
83 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('b')) {
|
|
84 isThere('b');
|
|
85 }
|
|
86 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('n')) {
|
|
87 isThere('n');
|
|
88 }
|
|
89 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('m')) {
|
|
90 isThere('m');
|
|
91 }
|
|
92 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('1')) {
|
|
93 hungryCheat('1');
|
|
94 }
|
|
95 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('2')) {
|
|
96 hungryCheat('2');
|
|
97 }
|
|
98 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('3')) {
|
|
99 hungryCheat('3');
|
|
100 }
|
|
101 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('4')) {
|
|
102 hungryCheat('4');
|
|
103 }
|
|
104 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar(' ')) {
|
|
105 resetCheat();
|
|
106 }
|
|
107
|
|
108 }
|
|
109 public char getKey () {
|
|
110 return pressKey;
|
|
111 }
|
|
112 public String getCheat(){
|
|
113 return cheat;
|
|
114 }
|
|
115
|
|
116 private void isThere(char c){
|
23
|
117 // Nie wiem czemu od razu nie przekazalem duzej litery...
|
0
|
118 pressKey=Character.toUpperCase(c);
|
|
119 resetCheat();
|
|
120 }
|
|
121 private void hungryCheat(char c){
|
|
122 String s =Character.toString(c);
|
|
123 cheat += s;
|
|
124 }
|
|
125 public void resetCheat(){
|
|
126 cheat="";
|
|
127 }
|
|
128 }
|