> ## Documentation Index
> Fetch the complete documentation index at: https://docs.comfy.org/llms.txt
> Use this file to discover all available pages before exploring further.

# ComfyUI Commands- und Tastenkürzel-API

> Registrieren Sie eigene Befehle und Tastenkürzel aus einer ComfyUI-Erweiterung, inklusive Syntax, Sondertasten und Grenzen.

Die Commands and Keybindings API ermöglicht es Erweiterungen, benutzerdefinierte Befehle zu registrieren und sie mit Tastenkürzeln zu verknüpfen. So können Sie Aktionen schnell auslösen, ohne die Maus zu benutzen.

## Grundlegende Nutzung

```javascript theme={null}
app.registerExtension({
  name: "MyExtension",
  // Befehle registrieren
  commands: [
    {
      id: "myCommand",
      label: "My Command",
      function: () => {
        console.log("Command executed!");
      }
    }
  ],
  // Tastenkürzel mit Befehlen verknüpfen
  keybindings: [
    {
      combo: { key: "k", ctrl: true },
      commandId: "myCommand"
    }
  ]
});
```

## Befehle konfigurieren

Jeder Befehl benötigt `id`, `label` und `function`:

```javascript theme={null}
{
  id: string,              // Eindeutige Kennung für den Befehl
  label: string,           // Anzeigename für den Befehl
  function: () => void     // Funktion, die beim Auslösen des Befehls ausgeführt wird
}
```

## Tastenkürzel konfigurieren

Jedes Tastenkürzel erfordert eine `combo` und eine `commandId`:

```javascript theme={null}
{
  combo: {                 // Tastenkombination
    key: string,           // Die Haupttaste (einzelnes Zeichen oder Sondertaste)
    ctrl?: boolean,        // Ctrl-Taste erforderlich (optional)
    shift?: boolean,       // Shift-Taste erforderlich (optional)
    alt?: boolean,         // Alt-Taste erforderlich (optional)
    meta?: boolean         // Meta/Command-Taste erforderlich (optional)
  },
  commandId: string        // ID des auszulösenden Befehls
}
```

### Sondertasten

Verwenden Sie für Nicht-Zeichentasten einen der folgenden Werte:

* Pfeiltasten: `"ArrowUp"`, `"ArrowDown"`, `"ArrowLeft"`, `"ArrowRight"`
* Funktionstasten: `"F1"` bis `"F12"`
* Weitere Sondertasten: `"Escape"`, `"Tab"`, `"Enter"`, `"Backspace"`, `"Delete"`, `"Home"`, `"End"`, `"PageUp"`, `"PageDown"`

## Befehlsbeispiele

```javascript theme={null}
app.registerExtension({
  name: "CommandExamples",
  commands: [
    {
      id: "runWorkflow",
      label: "Run Workflow",
      function: () => {
        app.queuePrompt();
      }
    },
    {
      id: "clearWorkflow",
      label: "Clear Workflow",
      function: () => {
        if (confirm("Clear the workflow?")) {
          app.graph.clear();
        }
      }
    },
    {
      id: "saveWorkflow",
      label: "Save Workflow",
      function: () => {
        app.graphToPrompt().then(workflow => {
          const blob = new Blob([JSON.stringify(workflow)], {type: "application/json"});
          const url = URL.createObjectURL(blob);
          const a = document.createElement("a");
          a.href = url;
          a.download = "workflow.json";
          a.click();
          URL.revokeObjectURL(url);
        });
      }
    }
  ]
});
```

## Beispiele für Tastenkürzel

```javascript theme={null}
app.registerExtension({
  name: "KeybindingExamples",
  commands: [
    /* Oben definierte Befehle */
  ],
  keybindings: [
    // Strg+R zum Ausführen des Workflows
    {
      combo: { key: "r", ctrl: true },
      commandId: "runWorkflow"
    },
    // Strg+Umschalt+C zum Leeren des Workflows
    {
      combo: { key: "c", ctrl: true, shift: true },
      commandId: "clearWorkflow"
    },
    // Strg+S zum Speichern des Workflows
    {
      combo: { key: "s", ctrl: true },
      commandId: "saveWorkflow"
    },
    // F5 zum Ausführen des Workflows (Alternative)
    {
      combo: { key: "F5" },
      commandId: "runWorkflow"
    }
  ]
});
```

## Hinweise und Einschränkungen

* Tastenkürzel, die im ComfyUI-Kern definiert sind, können nicht durch Erweiterungen überschrieben werden. Prüfen Sie die Kern-Tastenkürzel in diesen Quelldateien:
  * [Kernbefehle](https://github.com/Comfy-Org/ComfyUI_frontend/blob/e76e9ec61a068fd2d89797762f08ee551e6d84a0/src/composables/useCoreCommands.ts)
  * [Kern-Menübefehle](https://github.com/Comfy-Org/ComfyUI_frontend/blob/e76e9ec61a068fd2d89797762f08ee551e6d84a0/src/constants/coreMenuCommands.ts)
  * [Kern-Tastenkürzel](https://github.com/Comfy-Org/ComfyUI_frontend/blob/e76e9ec61a068fd2d89797762f08ee551e6d84a0/src/constants/coreKeybindings.ts)
  * [Reservierte Tastenkombinationen](https://github.com/Comfy-Org/ComfyUI_frontend/blob/e76e9ec61a068fd2d89797762f08ee551e6d84a0/src/constants/reservedKeyCombos.ts)

* Einige Tastenkombinationen sind vom Browser reserviert (etwa Ctrl+F für Suchen) und können nicht überschrieben werden

* Wenn mehrere Erweiterungen dasselbe Tastenkürzel registrieren, ist das Verhalten undefiniert


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.