Register Hotkeys
Register tool to accept global hotkeys, e.g. change tab, play game:
ts
import { Ipc } from "@vaguevoid/tools";
const unsubscribe = Ipc.registerGlobalHotkeys();
You can also pass a list of hotkeys to ignore and handle yourself:
ts
import { Ipc } from "@vaguevoid/tools";
const unsubscribe = Ipc.registerGlobalHotkeys({
ignore: ["togglePlay", "tabNavigation", "toggleCommandPalette"],
});
You can also check whether a hotkey is pressed on a keydown event:
ts
import { Ipc } from "@vaguevoid/tools";
const input = document.body.appendChild("input");
input.addEventListener("keydown", (e) => {
if (!Ipc.isGlobalHotkey(e)) {
e.stopPropagation();
}
});