Web应用课中期项目-拳皇
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
460 B

2 years ago
export class Controller {
constructor($canvas) {
this.$canvas = $canvas;
this.press_keys = new Set();
this.start();
}
start() { // 自定义按键事件,保证按下一个键只存一次键值
let outer = this;
this.$canvas.keydown(function(e) {
outer.press_keys.add(e.key);
});
this.$canvas.keyup(function(e) {
outer.press_keys.delete(e.key);
});
}
}