fix: 首次进游戏报错

This commit is contained in:
unanmed 2024-11-03 12:34:33 +08:00
parent bba3cb5e50
commit a3b6712bcc

View File

@ -200,7 +200,7 @@ export class Hotkey extends EventEmitter<HotkeyEvent> {
set(id: string, key: KeyCode, assist: number, emit: boolean = true) { set(id: string, key: KeyCode, assist: number, emit: boolean = true) {
const { ctrl, shift, alt } = unwarpBinary(assist); const { ctrl, shift, alt } = unwarpBinary(assist);
const data = this.data[id]; const data = this.data[id];
const before = this.keyMap.get(data.key)!; const before = this.keyMap.get(data?.key ?? KeyCode.Unknown)!;
deleteWith(before, data); deleteWith(before, data);
this.ensureMap(key); this.ensureMap(key);
const after = this.keyMap.get(key)!; const after = this.keyMap.get(key)!;