How to detect if the shift key is pressed?

Hi,

Is there a way to detect if a computer keyboard key is pressed ?
i'd like to set knob steps to 10 if shift is hold.
Thanks for your ideas.

Using a script widget and the VAR syntax:

shift_step_knob.json (2.6 KB)

1 Like

Thanks !
but your solution doesn't work on my computer :-)...

What i try to do is : steps are set to 11 when Shift is hold, 0 when not hold.

i propose you this that doesn't work : shift-knob-steps-no-working.json (3.4 KB)

Merci pour tes lumières !

It does work here, although the circular mode of the knob makes it harder to see somehow. The text widget is not affected because custom variables are scoped to widgets (VAR{steps} in widget A is different from VAR{steps} in widget B, hence the first argument in setVar() that defines in which widget the variable should be modified). Writing @{knob_1.steps} in the text's value should be enough to monitor the change of the property's value (not the variable "steps", but the property "steps").

ok now i can display the steps variable value and confirm it is well set :slight_smile: and Yes it works if i move the cursor over the knob : Great !

but if i press the shift key, it seems to disable the middle button of my mouse so the knob stays stuck. That's why i say it didn't work.
Without the Shift key pressed, i can use the molette to increase / decrease the knob value.

image

Edit : i add that your solution is wonderfull as it allows to set many knobs named knob_1, knob_2, knob_3 with the same behaviour using the universel selector *

setVar(
 `knob_*`,
 'steps',
  type == 'keydown' ? 6 : 0
)

The mousewheel issue will be fixed in next release.

1 Like