-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathControlsConsole.java
More file actions
44 lines (36 loc) · 902 Bytes
/
Copy pathControlsConsole.java
File metadata and controls
44 lines (36 loc) · 902 Bytes
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
import hsa.*;
import java.awt.event.*;
public class ControlsConsole extends hsa.Console
{
private boolean [] _keys;
public ControlsConsole(){
super();
_keys = new boolean[26];
for (int i = 0; i < 26; i++){
_keys[i] = false;
}
}
public ControlsConsole(int columns, int rows){
super(columns, rows);
_keys = new boolean[26];
for (int i = 0; i < 26; i++){
_keys[i] = false;
}
}
public boolean isKeyDown(char c){
c -= 'A';
return _keys[c];
}
public synchronized void keyPressed (KeyEvent e){
int key = e.getKeyCode() - 'A';
if (key <= 26 && key >= 0)
_keys[key] = true;
super.keyPressed (e);
}
public synchronized void keyReleased (KeyEvent e){
int key = e.getKeyCode() - 'A';
if (key <= 26 && key >= 0)
_keys[key] = false;
super.keyReleased (e);
}
}