2020-05-10 22:47:03 +00:00
|
|
|
import { KeyHandler, KeyName } from "../applet/Keyboard";
|
2020-02-16 04:15:59 +00:00
|
|
|
|
|
|
|
export class Buttons implements KeyHandler {
|
|
|
|
|
|
|
|
keys: KeyName[] = [];
|
|
|
|
|
|
|
|
public update(key: KeyName, state: "press" | "release") {
|
|
|
|
const newKeys = this.keys.filter(k => k != key);
|
|
|
|
if(state == "press") {
|
|
|
|
newKeys.push(key);
|
|
|
|
newKeys.sort();
|
|
|
|
}
|
|
|
|
this.keys = newKeys;
|
|
|
|
}
|
|
|
|
|
|
|
|
public block() {
|
|
|
|
this.keys = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
public getPressed(): KeyName[] {
|
|
|
|
return this.keys.slice();
|
|
|
|
}
|
|
|
|
}
|