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); }); } }