I don't understand what the problem is. But I think I had a similar problem some time ago. In my Text Editor template I have implemented the controls "ALT + N", "CTRL + O", "CTRL + S", "CTRL + SHIFT + S", "CTRL + R". I used this code:
- keyboardShortcuts.js
Link:
- GitHub
- demo
In your code, I would first try to replace window with globalThis (see this).