Nodes/opencv-comfyui/OpenCV waitKeyEx_0
ComfyUI Node

OpenCV waitKeyEx_0

WaitKey, but with extended key codes — same ComfyUI caveats apply

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV waitKeyEx_0
    • int
    delay

    waitKeyEx is OpenCV's "give me the fancy keys too" version of waitKey. Where plain waitKey returns ASCII-ish codes that can't distinguish arrow keys or function keys properly, waitKeyEx returns extended codes so you can tell Left from Right, F1 from F2. In a desktop OpenCV script that's a genuinely useful upgrade - it's how you build keyboard-navigable viewers. Inside ComfyUI, it inherits every limitation of its little sibling and adds nothing for the node-graph case.

    waitKeyEx_0 has exactly one input and one output: delay (INT, milliseconds to wait) and int (the extended key code). In a headless or browser-run ComfyUI there's no OpenCV window to receive key events, so it blocks for delay ms and returns -1 every time. Its realistic role, same as waitKey_0, is a crude timer that stalls the graph - and even then, a dedicated delay node is the cleaner choice.

    The only scenario where it shines

    You'd reach for the Ex variant over the plain one in exactly one setup: a local desktop ComfyUI where you've wired in imshow_0 to pop a real OpenCV window and you want to branch on which key the user pressed mid-graph. In that narrow case the extended codes matter - an arrow key or spacebar gives you a distinct return value you could theoretically route through a conditional. Practically, building interactive branching in ComfyUI this way is a fight against the architecture, and you'd be happier doing the interaction in a script node. The author's own framing for the pack is honest about this: these nodes are for small, quick, deterministic transforms (a blur, an edge detect), not for reimplementing interactive OpenCV apps inside Comfy.

    Installing

    Same as every node in the pack. ComfyUI Manager, search "opencv-comfyui", install, restart, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/geroldmeisinger/opencv-comfyui
    

    Dependencies from requirements.txt: opencv-contrib-python, numpy, torch.

    Bottom line

    waitKeyEx_0 is a faithful wrapper of a real OpenCV function that mostly doesn't belong in a node graph. If you stumbled on it expecting a keyboard-input node, know that it only works on a local machine with a real display and an imshow window, and that the pack's 600+ other nodes contain far more useful things to build with. Set delay to a small number, ignore the output, or skip it entirely.

    Categoryimage/OpenCV

    Inputs (1)

    NameTypeDefaultDescription
    delayINT

    Outputs (1)

    NameTypeDescription
    intINT