Is there any way to intercept the Spacebar (VK_SPACE) natively within a Ruby Tool class?

Hello everyone,

I’m currently developing a custom interactive Ruby tool for SketchUp. For my tool’s specific workflow, it would be extremely ergonomic for the user to cycle through some temporary alignment options by pressing the space key while my tool is active.

However, I’ve run into the well-known limitation where SketchUp’s native shortcut accelerator intercepts the spacebar (to switch to the Select tool) before it even reaches my tool’s onKeyDown callback. I am perfectly able to capture other keys like tab or the arrow keys, but VK_SPACE is swallowed by the host application.

I am aware that relying on an invisible UI::HtmlDialog to steal window focus is a workaround to capture keydown events, but I am looking for a purely native ruby tool approach.

Is there any known API trick, native workaround, or event hook to temporarily bypass the workspace shortcut and capture space exclusively for my tool while it is active, without forcing the user to manually erase their keyboard shortcuts map?

Any insights would be greatly appreciated. Thanks!

SPACE is the wrong key to use for this.

Please follow convention of the native Move tool and use ALT (Win) / OPTION (Mac).

To see how it works with a component instance selected activate the MoveTool.
Please notice the prompts on the status bar and the one for ALT.
Then tap the ALT key to see how the grips change. Repeat, etc.

Your tool should work the same way.

2 Likes

Thanks for the guidance, Dan. I didn’t realize that using Alt/Option was the standard for cycling options like the Move tool. I’ve just implemented it and it works seamlessly, without any of the shortcut conflicts I was facing. Thanks for saving my day!

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.