comparison kopieckreta/src/Actions.java @ 0:2787f5e749ae

INIT
author prymula <prymula76@outlook.com>
date Thu, 21 Sep 2023 22:33:57 +0200
parents
children 489244127359
comparison
equal deleted inserted replaced
-1:000000000000 0:2787f5e749ae
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('ą')) {
27 isThere('ą');
28 }
29 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('w')) {
30 isThere('w');
31 }
32 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('e')) {
33 isThere('e');
34 }
35 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('ę')) {
36 isThere('ę');
37 }
38 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('r')) {
39 isThere('r');
40 }
41 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('t')) {
42 isThere('t');
43 }
44 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('y')) {
45 isThere('y');
46 }
47 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('u')) {
48 isThere('u');
49 }
50 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('i')) {
51 isThere('i');
52 }
53 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('o')) {
54 isThere('o');
55 }
56 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('ó')) {
57 isThere('ó');
58 }
59 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('p')) {
60 isThere('p');
61 }
62 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('s')) {
63 isThere('s');
64 }
65 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('ś')) {
66 isThere('ś');
67 }
68 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('d')) {
69 isThere('d');
70 }
71 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('f')) {
72 isThere('f');
73 }
74 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('g')) {
75 isThere('g');
76 }
77 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('h')) {
78 isThere('h');
79 }
80 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('j')) {
81 isThere('j');
82 }
83 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('k')) {
84 isThere('k');
85 }
86 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('l')) {
87 isThere('l');
88 }
89 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('ł')) {
90 isThere('ł');
91 }
92 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('z')) {
93 isThere('z');
94 }
95 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('ż')) {
96 isThere('ż');
97 }
98 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('ź')) {
99 isThere('ź');
100 }
101 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('c')) {
102 isThere('c');
103 }
104 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('ć')) {
105 isThere('ć');
106 }
107 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('b')) {
108 isThere('b');
109 }
110 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('n')) {
111 isThere('n');
112 }
113 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('ń')) {
114 isThere('ń');
115 }
116 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('m')) {
117 isThere('m');
118 }
119 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('1')) {
120 hungryCheat('1');
121 }
122 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('2')) {
123 hungryCheat('2');
124 }
125 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('3')) {
126 hungryCheat('3');
127 }
128 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('4')) {
129 hungryCheat('4');
130 }
131 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar(' ')) {
132 resetCheat();
133 }
134
135 }
136 public char getKey () {
137 return pressKey;
138 }
139 public String getCheat(){
140 return cheat;
141 }
142
143 private void isThere(char c){
144 // Nie wiem czemu od razu nie przekazałem dużej litery...
145 pressKey=Character.toUpperCase(c);
146 resetCheat();
147 }
148 private void hungryCheat(char c){
149 String s =Character.toString(c);
150 cheat += s;
151 }
152 public void resetCheat(){
153 cheat="";
154 }
155 }