> ## 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.

# Comandos y atajos de teclado

> Domina los comandos y atajos de teclado de Comfy para registrar acciones y atajos personalizados en tus extensiones.

La API de Commands y Keybindings permite que las extensiones registren comandos personalizados y los asocien a atajos de teclado. Así, los usuarios pueden activar acciones rápidamente sin usar el mouse.

## Uso básico

```javascript theme={null}
app.registerExtension({
  name: "MyExtension",
  // Register commands
  commands: [
    {
      id: "myCommand",
      label: "My Command",
      function: () => {
        console.log("Command executed!");
      }
    }
  ],
  // Associate keybindings with commands
  keybindings: [
    {
      combo: { key: "k", ctrl: true },
      commandId: "myCommand"
    }
  ]
});
```

## Configuración de comandos

Cada comando requiere un `id`, un `label` y una `function`:

```javascript theme={null}
{
  id: string,              // Unique identifier for the command
  label: string,           // Display name for the command
  function: () => void     // Function to execute when command is triggered
}
```

## Configuración de las combinaciones de teclas

Cada combinación de teclas requiere un `combo` y un `commandId`:

```javascript theme={null}
{
  combo: {                 // Combinación de teclas
    key: string,           // La tecla principal (un solo carácter o una tecla especial)
    ctrl?: boolean,        // Requiere la tecla Ctrl (opcional)
    shift?: boolean,       // Requiere la tecla Shift (opcional)
    alt?: boolean,         // Requiere la tecla Alt (opcional)
    meta?: boolean         // Requiere la tecla Meta/Command (opcional)
  },
  commandId: string        // ID del comando que se va a activar
}
```

### Teclas especiales

Para las teclas que no son caracteres, usa uno de estos valores:

* Flechas: `"ArrowUp"`, `"ArrowDown"`, `"ArrowLeft"`, `"ArrowRight"`
* Teclas de función: `"F1"` hasta `"F12"`
* Otras teclas especiales: `"Escape"`, `"Tab"`, `"Enter"`, `"Backspace"`, `"Delete"`, `"Home"`, `"End"`, `"PageUp"`, `"PageDown"`

## Ejemplos de comandos

```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);
        });
      }
    }
  ]
});
```

## Ejemplos de atajos de teclado

```javascript theme={null}
app.registerExtension({
  name: "KeybindingExamples",
  commands: [
    /* Commands defined above */
  ],
  keybindings: [
    // Ctrl+R to run workflow
    {
      combo: { key: "r", ctrl: true },
      commandId: "runWorkflow"
    },
    // Ctrl+Shift+C to clear workflow
    {
      combo: { key: "c", ctrl: true, shift: true },
      commandId: "clearWorkflow"
    },
    // Ctrl+S to save workflow
    {
      combo: { key: "s", ctrl: true },
      commandId: "saveWorkflow"
    },
    // F5 to run workflow (alternative)
    {
      combo: { key: "F5" },
      commandId: "runWorkflow"
    }
  ]
});
```

## Notas y limitaciones

* Las extensiones no pueden sobrescribir los atajos de teclado definidos en el núcleo de ComfyUI. Revisa los atajos de teclado del núcleo en estos archivos fuente:
  * [Comandos del núcleo](https://github.com/Comfy-Org/ComfyUI_frontend/blob/e76e9ec61a068fd2d89797762f08ee551e6d84a0/src/composables/useCoreCommands.ts)
  * [Comandos del menú del núcleo](https://github.com/Comfy-Org/ComfyUI_frontend/blob/e76e9ec61a068fd2d89797762f08ee551e6d84a0/src/constants/coreMenuCommands.ts)
  * [Atajos de teclado del núcleo](https://github.com/Comfy-Org/ComfyUI_frontend/blob/e76e9ec61a068fd2d89797762f08ee551e6d84a0/src/constants/coreKeybindings.ts)
  * [Combinaciones de teclas reservadas](https://github.com/Comfy-Org/ComfyUI_frontend/blob/e76e9ec61a068fd2d89797762f08ee551e6d84a0/src/constants/reservedKeyCombos.ts)

* Algunas combinaciones de teclas están reservadas por el navegador (como Ctrl+F para buscar) y no se pueden sobrescribir

* Si varias extensiones registran la misma combinación de teclas, el comportamiento no está definido


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