KeyDown events to control mesh growth behavior - Advice needed

Hi All,

I am working on a grasshopper component that allows the user to “paint” a growth behavior onto a mesh surface:
MG_Overview_Post_1
MG_Close_Post_1_3

Currently, I am looking to further control the script with KeyDown events:

Eg. Holding down “Alt” to remove the painted operation for the current mouse region.

Or Multiple KeyDown events:

Eg. Holding down “Control” + “A” will paint a modified behavior.

What is the best methodology to achieve this?

The component is written in C# targeting .Net7.0 in VS. I understand this process can potentially be done via Eto.Forms.Keyboard.Modifiers however any advice, example key event scripts, or links to reference material would be much appreciated!

1 Like

As an alternative, on Windows you can use a low level approach by using user32.dll.
I don’t know if misusing Grasshopper like this is good, but your project looks quite interesting!

[DllImport(“user32.dll”)]
private static extern short GetAsyncKeyState(int vKey);

You find all keycodes here:

where the left-ALT key is exposed as 0xA4 (=164)

1 Like

Thanks @TomTom - I will give this method a go!

:open_mouth: :exploding_head: oh em gee :smiley: :beers:awesome!

1 Like