fix(keybinds): Prevent crash on keypress before settingClass is initialized #27

Merged
Jade merged 2 commits from cwcinc/PolyModLoader:0.6.3 into 0.6.3 2026-10-10 22:55:54 +02:00
Contributor

Mod keybind listeners are added to window as soon as registerKeybind is called, but settingClass is only set when PolyTrack first builds its settings. A keypress in between throws TypeError: Cannot read properties of undefined (reading 'checkKeyBinding') and brings up the error screen.

This bug can be reproduced in the current version by pressing keys as the game loads. Any keyboard event can trigger this error.

This fix changes this.settingClass.checkKeyBinding(...) to this.settingClass?.checkKeyBinding(...). Until settingClass exists, the condition is falsy (undefined), so the keypress is ignored and the callback doesn't run. Once the game builds its settings, keybinds work as before.

Mod keybind listeners are added to window as soon as registerKeybind is called, but settingClass is only set when PolyTrack first builds its settings. A keypress in between throws TypeError: Cannot read properties of undefined (reading 'checkKeyBinding') and brings up the error screen. This bug can be reproduced in the current version by pressing keys as the game loads. Any keyboard event can trigger this error. This fix changes this.settingClass.checkKeyBinding(...) to this.settingClass?.checkKeyBinding(...). Until settingClass exists, the condition is falsy (undefined), so the keypress is ignored and the callback doesn't run. Once the game builds its settings, keybinds work as before.
Jade merged commit aea33b2b25 into 0.6.3 2026-10-10 22:55:54 +02:00
Owner

never thought I'd see the day cwc does something for pml

never thought I'd see the day cwc does something for pml
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
polytrackmods/PolyModLoader!27
No description provided.