Safe Hot Keys

Here is an article that explains a bit about the differences between Return and Enter:

Given that Return on Mac and Enter on Windows is used by people for entering values into the measurements box, I would not use it for an extension, other than for an input commit on your own extension’s windows.

2 Likes

I’ve also had issues with trying to use the Enter key when it comes to MacOS.

I commonly use the Control key for a hotkey when it comes to my extensions and I’ve also used the arrow keys however I am looking for one more hot key that I can use when I am already using the Control key in one of my tools.

I’m kind of at a loss right now.

I’ve tried and had issues with all of the following keys:

Tab, Shift, Alt and Enter

What should I use for a secondary hot key? and I would rather use a single key not a bunch of key combinations, that just makes things too complicated.

Shift would be the safest of those. Alt will trigger the Windows menubar, if you can’t trap it.

1 Like

The Shift key modifies the inferencing.

I guess the only keys that might work are the arrow keys.

Arrow keys are used to lock inferences in tools.

Since shortcuts are user configurable, there isn’t any “safe” combo.

What is the context here? Defining a shortcut key programatically?

1 Like

On MAC pressing Tab only fires on KeyUp, so use that because otherwise MAC will ignore any KeyDown events for Tab…
KeyUp with Tab works on PC or MAC - different key code for the OSs though.

if key==9 || key==15 ### TAB = 9 for PC, or 15 for MAC ?...

I just want to define one more hotkey for my draw wall tool and I already have the Control key setup to do some stuff so I need another key that won’t affect any other Window or SketchUp stuff, and it needs to work for both Mac and Windows.

The Tab key seems problematic since Mac users require the Tab key to enter in values into the VCB.

What about making the thing you want a hotkey for into a menu item such that the user can configure their own hotkey?

2 Likes

I second what Colin said. Stay away from TAB and ENTER (they’re used for input control.)
And ESC is traditionally used for tool state reset, ARROW keys for axes locking.

I think ALT can be used if onKeyUp returns true.


I like Thomas’ idea of letting the user decide.

If you hardset it to [ `/~ ] or [ 1/! ], I’d not like that because I have those set for something else.

1 Like

I really have no idea how you let the user decide.

So basically only the Control key is “safe” hot key I can use for my plugins. So what do other plugin author use when they need a secondary hot key?

I use Ctrl, Shift and Alt frequently.

Ctrl is used for copy (if it applies), shift for inference geometry looking (if it applies) and Alt for sampling (if it applies). Arrow keys are for inference axis looking (if it applies).

Since many tools have other functionality you can use them more freely. Paint Bucket by nature can’t copy or look inference, so here Ctrl, Shift and a combination of the two are used for spreading the material to other faces. Move has no sample but use Alt to allow for folding faces.

In rare cases it could even make sense to use arrow keys for other things than axes looking. If I made a first person walk tool, I’d use arrow keys to walk.

If a tool has more options than can fit onto the modifier keys, I sometimes also use the tool context menu, similarly to the position material tool.

I hope that info helps. What modifier/option are you currently designing for your tool?

1 Like

What kind of functionality are we talking about?

Modifier keys like the native tools? Or invoking separate commands?

1 Like

I need to assign a hot key for wall justification. This hotkey will toggle the placement of the wall (ie. front, back or center) given the two points the users selects.

I’m currently trying to use the Tab key but that seems to be problematic for Mac users.

Gotcha. So we’re looking at a modifier action. I’d model the mode switch after the native tools. Tapping Ctrl (and whatever the macOS variant is). Combine it with cursors indicating the current mode.

The problem is that I am already using the Ctrl key for another hot key action (locking the wall into a 45 or 135 degree configuration).

I am trying to find a different hot key to use for the wall justification.

The Shift key is used for locking contraints with SU’s own tools. Could that be a good option for you?

Sounds like if you used Shift for the angle constraint and Ctrl for the mode toggle you’d be aligning well with SU’s own tools.

1 Like

The current Walk tool already does use the arrow keys for turning the camera, and for moving forward and backward. It isn’t exactly like FPS, but it is an existing example of where the arrow keys are used for something other than axis locking.

1 Like

And the MoveTool is an example of a tool that uses the ALT modifier as a mode toggle (for AutoFold in this case.)

I’ve never been able to successfully use the Alt key as a modifier/hot key. It triggers something in Windows and essentially freezes up the SketchUp window or something along those lines. If I could suppress that behavior then it would work.