mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-11-18 20:27:11 +08:00
31 lines
894 B
JavaScript
31 lines
894 B
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 = {
|
|
"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);
|
|
}
|
|
}); |