|
|
|
|
|
by chrismorgan
2200 days ago
|
|
Drop it in a user script with Greasemonkey or similar, and add a keypress event listener. The bones of it: // ==UserScript==
// @name Personal jmapui tweaks
// @version 1
// @grant none
// ==/UserScript==
addEventListener("keypress", event => {
if (event.target …) { return; }
if (event.key == 'x' && event.ctrlKey && !event.metaKey …) {
window.eval('…');
}
});
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. |
|