Skip to content

Commit 6e931b6

Browse files
authored
Update Reroute.js
Added the ability to configure a node using arrow keys.
1 parent ba9ce84 commit 6e931b6

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

js/Reroute.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// ComfyUI.mxToolkit.Reroute v.0.9c - Max Smirnov 2024
1+
// ComfyUI.mxToolkit.Reroute v.0.9d - Max Smirnov 2024
22
import { app } from "../../scripts/app.js";
33
import { mergeIfValid, getWidgetConfig, setWidgetConfig } from "../core/widgetInputs.js";
44

@@ -17,6 +17,7 @@ app.registerExtension({
1717
this.properties.outputDir= "RIGHT";
1818
this.linkType = "*";
1919
this.bgcolor="rgba(20,20,200,0.0)";
20+
this.keyCode = 0;
2021

2122
this.size = [2*LiteGraph.CANVAS_GRID_SIZE + 1.4*LiteGraph.NODE_SLOT_HEIGHT, 2*LiteGraph.CANVAS_GRID_SIZE + 1.4*LiteGraph.NODE_SLOT_HEIGHT];
2223

@@ -73,7 +74,22 @@ app.registerExtension({
7374
ctx.fill();
7475
}
7576
}
76-
77+
78+
this.onKeyUp = function(e)
79+
{
80+
if (e.keyCode < 37 || e.keyCode > 40) return;
81+
if (this.keyCode > 0)
82+
{
83+
const arrowKeys = { 37: "LEFT", 38: "UP", 39: "RIGHT", 40: "DOWN"};
84+
this.properties.inputDir = arrowKeys[this.keyCode];
85+
this.properties.outputDir = arrowKeys[e.keyCode];
86+
this.onPropertyChanged();
87+
this.keyCode = 0;
88+
} else this.keyCode = e.keyCode;
89+
}
90+
91+
this.onDeselected = () => {this.keyCode = 0};
92+
7793
this.getExtraMenuOptions = function()
7894
{
7995
var that = this;
@@ -94,7 +110,7 @@ app.registerExtension({
94110
{content:"⮠", callback: function() { that.properties.inputDir = "UP"; that.properties.outputDir = "LEFT"; that.onPropertyChanged(); }},
95111
];
96112
}
97-
113+
98114
this.onPropertyChanged = function ()
99115
{
100116
const aValues = ["LEFT","RIGHT","UP","DOWN","TOP"];

0 commit comments

Comments
 (0)