mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-11-18 20:27:11 +08:00
36 lines
1.0 KiB
JavaScript
36 lines
1.0 KiB
JavaScript
import { app } from "/scripts/app.js";
|
|
|
|
const id = "Comfy.Keybinds";
|
|
app.registerExtension({
|
|
name: id,
|
|
init() {
|
|
const keybindListener = function(event) {
|
|
const target = event.composedPath()[0];
|
|
|
|
if (target.tagName === "INPUT" || target.tagName === "TEXTAREA") {
|
|
return;
|
|
}
|
|
|
|
const keyToButtonIdMap = {
|
|
"Enter": "queue-button",
|
|
"f": "queue-front-button",
|
|
"q": "view-queue-button",
|
|
"h": "view-history-button",
|
|
"s": "save-button",
|
|
"l": "load-button",
|
|
"r": "refresh-button",
|
|
"c": "clear-button",
|
|
"d": "load-default-button",
|
|
};
|
|
|
|
const buttonId = keyToButtonIdMap[event.key];
|
|
if (buttonId) {
|
|
const button = document.querySelector(`#${buttonId}`);
|
|
button.dispatchEvent(new Event("click"));
|
|
}
|
|
}
|
|
|
|
document.addEventListener("keyup", keybindListener);
|
|
}
|
|
});
|