Cabbage Logo
Back to Cabbage Site

Computer keyboard detection

Hey! I am working on using cabbage for a project of live electronics. I will be exporting it as a standalone application (thanks for this feature, very nice). I would like to be able to control small things with for example the spacebar. I have been looking around, but I cannot find a clear way on how to do it. I have tried the KEY_PRESSED channel, but it does not print anything when using cabbage.

Anyone able to point me in the right direction?
(ignore the mouse variables haha. They are working tho!)

instr 1

  kMouseX chnget "MOUSE_X"
  kMouseY chnget "MOUSE_Y"
  kCurrentKey chnget "KEY_PRESSED"
  printk 0.1, kCurrentKey

That should work. I can only assume instrument 1 is not playing? Here is a csd that works for me here, just make sure the instrument has focus in Cabbage.

form caption("Untitled") size(400, 300), guiMode("queue") pluginId("def1")
button bounds(10, 10, 143, 38), latched(0), channel("button1"), text("Button")
-n -d
ksmps = 32
nchnls = 2
0dbfs = 1

instr 1
    kTrig chnget "KEY_DOWN"
    kKey chnget "KEY_PRESSED"
    printf "Key:%d", kTrig, kKey

i1 0 z

p.s. I just noticed that this won’t work unless there are some controls on the instrument. I guess the keypresses are passed through the widgets.

huh, not sure why it wasn’t working on my end, then. but thanks a lot :smiley: