-
Notifications
You must be signed in to change notification settings - Fork 1
/
UserInput.java
57 lines (50 loc) · 1.46 KB
/
UserInput.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import java.awt.event.KeyEvent;
import java.awt.event.KeyAdapter;
import javax.swing.JFrame;
public class UserInput {
public static void main(String args[]){
JFrame myJFrame = new JFrame();
myJFrame.setVisible(true);
myJFrame.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
int keyCode = e.getKeyCode();
if (keyCode == KeyEvent.VK_W) {
Window.wpress();
}
else if (keyCode == KeyEvent.VK_S) {
Window.spress();
}
else if (keyCode == KeyEvent.VK_A) {
Window.apress();
}
else if (keyCode == KeyEvent.VK_D) {
Window.dpress();
}
else if (keyCode == KeyEvent.VK_Q) {
Window.qpress();
}
else if (keyCode == KeyEvent.VK_R) {
Window.rpress();
}
else if (keyCode == KeyEvent.VK_E) {
Window.epress();
}
else if (keyCode == KeyEvent.VK_F) {
Window.fpress();
}
else if (keyCode == KeyEvent.VK_UP) {
Window.uppress();
}
else if (keyCode == KeyEvent.VK_DOWN) {
Window.downpress();
}
else if (keyCode == KeyEvent.VK_LEFT) {
Window.leftpress();
}
else if (keyCode == KeyEvent.VK_RIGHT) {
Window.rightpress();
}
}
});
}
}