A prototype way of interacting with Grasshopper with the keyboard. Press any character key on the keyboard to send true/false values to Grasshopper.
It uses the Global Mouse and Keyboard Hook classes by George Mamaladze to intercept key up/down events. I have written two components that turns these key events into true/false commands – if a key is raised, ‘false’ is sent, and if pressed, ‘true’ is sent.
In the component above, 6 keys have been hard-coded. (I have been using this as part of video game-like WASD camera control in Rhino.) The component below accepts any character (and possibly any key on the keyboard if you’re lucky enough to find the correct character code for each key.)
Install
To install, download the file at the bottom of this page. Unzip and copy the two files (one GHA and one DLL) into your Grasshopper components folder. To use, set up as in the images above, and remember to attach a timer with a short interval. You may need to unblock the file within Windows if you are having problems. (Right click each of the two files in Windows Explorer, click Properties, and click Unblock.)
Keyboard reader for Grasshopper
Source code
The source code of the Grasshopper components is available at GitHub.
The classes for interacting with the keyboard must (at least for the moment) be downloaded separately, and are available here.
Hi! the link “download” is broken… 🙁
That redirect to http://james-ramsden.com/?wpdmact=process&did=Mi5ob3RsaW5r
where only is the home page.
Could you upload the zip again or share the .gha in gitup?
Thanks, nice work !
Ah, where did it go?? I have added a new copy – let me know how you get on 🙂
James — this is awesome… I’m thinking about implementing this in concert with Human’s Clickable Mesh — since Clickable mesh intercepts all mouse clicks and can’t really be always on. That said, did you explore using an event-based model as opposed to a GH timer? I try to avoid timers at all costs…
Cheers,
Marc
Incidentally — I was not able to get this to work… I used the provided components and all the gha + dlls are loading properly (no error messages). The sample file comes up with serialization errors and outputs appear to be mislabeled. Perhaps this is an issue with being an old file written for a different environment? I’m on Windows 10, Rhino 5, and GH 0.9.0076…
I guess you unblocked the DLL? I have just tested, and got as far as clearing any errors, but I can’t get it to work either. I originally wrote/tested it on Win7, and I’m now on Win10, so it’s possible that’s the source of the issue.
It was a while back, but I believe the reason was only my own time – adding a GH timer got the job done. It would certainly be much better with a proper timer built in.