You’ll want to do things like skip events targeted at form elements or within a contenteditable, perhaps unless you use a suitable modifier.
It may be helpful to flatten the modifiers and key into a single string, like "Ctrl-Meta-Shift-S", and match on that.
The security interactions between your user script code and document code are fiddly and troublesome, and debugging is distressingly limited. I find using window.eval(`…`) to be a good technique for executing arbitrary code in the security context of the page itself.
The bones of it:
You’ll want to do things like skip events targeted at form elements or within a contenteditable, perhaps unless you use a suitable modifier.It may be helpful to flatten the modifiers and key into a single string, like "Ctrl-Meta-Shift-S", and match on that.
The security interactions between your user script code and document code are fiddly and troublesome, and debugging is distressingly limited. I find using window.eval(`…`) to be a good technique for executing arbitrary code in the security context of the page itself.