In-command hot keys

I have a plug-in made using C# and am wondering if there is a way to change what specific keys on a keyboard do while being inside a command?
I’d like to use either a letter or arrows to rotate a part with one button press instead of button+enter/space.

I want to change the behaviour only while being inside the command, such that the same procedure doesn’t get triggered when trying to type something or it replacing other functionality outside the command.

Hi @siemen,

Try hooking the keyboard.


– Dale

1 Like

@dale Thanks a lot!

Hi Dale,
This works, but it seems like it still registers what the key does when it would be outside of the command. Is it possible to temporarily turn off other keyboardevents related to that key?

You can see it registers both the nudge as well as the keypress.

Perhaps I need to give a bit more context:
I have a plug-in with a command that does a few things and then it asks the user to give the new position for a part. I’m using a custom GetPoint class to show the preview of the curve and in the commandline is an option to rotate the part 90 degrees. I’d like to make that rotate 90 degrees part easier with just 1 button press. So during the custom GetPoint.Get() I need to somehow register pressing a specific button which then triggers the same things that happens when you press the command line option or press the Shortcut letter + Enter

This is what I currently have:

            var gp = new GetPointCurve(crvs, cpt, xformsgp);
            gp.SetCommandPrompt("Select location of object");


            //Add keyboard button tracking for rotating easily
            RhinoApp.KeyboardEvent += OnRhinoKeyboardEvent;

            while (true)
                var res = gp.Get();
                if (res == GetResult.Cancel)
                    RhinoApp.KeyboardEvent -= OnRhinoKeyboardEvent;
                    return Result.Cancel;

                if (res == GetResult.Option)

                    newLocation = gp.Point();

            RhinoApp.KeyboardEvent -= OnRhinoKeyboardEvent;
private static void OnRhinoKeyboardEvent(int key)
            int VK_LEFT = 0x25;
            int VK_RIGHT = 0x27;
            //int VK_R = 0x52;

            if (key == VK_LEFT)
            if (key == VK_RIGHT)

As you can see I tried writing the text in the command line and it does, but it doesn’t register as entering the text and pressing enter.

Ok, so I ended up doing a work around by using AcceptNothing(true); Then the user can use spacebar to rotate the part.

I’m still interested in how I would go about using keyboard presses for being able to rotate it left or right