I need to read (one or more) key presses in Python and I would like to avoid using a Form.
Is it possible?
I made a simple dummy script that tries to use msvgetch but it seems to ignore the key presses as these only results in letters on the Rhino commandline:
import msvcrt
import rhinoscriptsyntax as rs
print "press a key..."
for i in range(100):
rs.Sleep(20)
char = msvcrt.getche()
rs.Sleep(20)
if char == chr(27):
break
print char
```
Getting individual character presses is currently pretty hard with the way the Rhino is set up if you are not using a Form. There is always the GetString function too.
Ok, then please add a wish for that.
A tool to check for any key press, ala escape_test would be perfect.
Both press and release if those are two different values, and multiple keys.
@Holo, I’ve added a new GetKey function to RhinoScript in the WIP. If you don’t mind, can you check this out and see if its what you are looking for? If so, then I can provide a similar function in RhinoCommon.
Hi Dale,
I can’t find it…
There is nothing in rhinoscriptsyntax nor in Rhino.input. that I can find.
(Not rant) And how do you expect me to find it? Searching is possible in rhinoscriptsyntax but it returns nothing, nor can I find it in “Rhino”, which isn’t searchable either. It would be a great help if it was. (And wouldn’t it make more sense to rename “Rhino” RhinoCommon?)
Oh… I thought python was the new norm as it was more platform independent. That’s why I took the leap a few years back. And the tool I need it for is made in Python. I’ll see what I can do but it won’t be my top priority for the next few days. My advice is port it to Common and we’ll see if it’s worthy there. Then it can be tested in a real scenario.
All at once, and you clearly need to game more!
It is the default for all VR and FPS gaming where keyboard is used for input.
WASD for navigation instead of arrow keys, and then add shift for run (hold down) and press space to jump.
So if you press and hold W+A+shift then you run diagonally forward/left.
Hi Dale, do you think you’ll find a way to implement multiple keypresses?
If not then add the single key press, that is at least a huge step forward from nothing.
Hi Dale!
I would really like to have this up and running for V6.
All I need is to be able to read the different KeyDown, KeyUp and KeyPress’. Do you think you could implement it?
Hi Dale,
Does that mean you’ll solve it soon, or that it just has been logged?
I would really REALLY love to see this incorporated.
And as stated earlier single key press is a huge step forward from what nothing so please integrate that first if possible.
Its on the list. And while you request is important, we feel there are many other issues that need to be fixed or implemented for Rhino 6. Thus, my attention is on those issues.