Read keypress without a Form?

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):
    char = msvcrt.getche()
    if char == chr(27):
    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.

I need it for the walkabout tool I am working on.

Okay, added to the wishlist at

@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.

– Dale

Nice! What build is that in? next week or the current one?

The GetKey function has been in the WIP for a while…

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?)


The function was added to RhinoScript (VBS). I’m trying to determine whether or not the function is worthy of porting to 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.

Hi Dale.
I did a very easy test and I can’t get it to handle multiple keypresses.
Example: Shift + A + W = Run diagonally, and then add Space to jump.

So four keypresses at once is a minimum for normal point of view first person exploration.

Edit: Do you think it’s possible to add this?

Is this, press Shift + A and then W, or all at once? All at once seem a little odd - not sure I’ve seen an application that has this type of input.

All at once, and you clearly need to game more! :smiley:
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 Jørgen,

Your wish is on the list:

– Dale

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.

Hi Jørgen,

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.

– Dale