MenuItem Hotkey Always Active

I added a MenuItem to an editor script with the hotkey shift-H (to match the show selection behavior of in Maya).

It seems that this hotkey is always active, even when entering text. With it enabled I can’t use capital H when typing anywhere in the Unity Editor (entering object names in a tree view, text in any of the search windows, etc.). The key press is intercepted by the MenuItem and the H just doesn’t appear. I thought my keyboard was broken or something.

Is there a way to limit where a hotkey is active?
Has anyone else run into this?
Should I be reporting an editor bug/feature request (I’d call it a bug myself)?

As an aside, it turns out that it would be a great prank to disable a single capital letter on someone’s keyboard. It really drives you crazy to have one capital key just not work for no apparent reason. Because nothing was hidden in my scene there was no side effect to hitting Shift-H. The MenuItem was being invoked, but nothing at all would happen so it wasn’t immediately apparent it was the hotkey addition made some time ago that was causing the capital H to stop working.

It shouldn’t fire if you in textfield or renaming assets. Assuming you are talking about MenuItem (it doesn’t work that way for me).

Yes, you can validate it:
https://docs.unity3d.com/ScriptReference/MenuItem.html

That’s interesting. Yeah, it’s firing for me in the project asset view when I try to rename an object, and consuming the keypress, so I get no capital H’s.

[MenuItem(“Display/Show/Show Selection #h”)]
static void ShowSelected()
{
foreach (Transform t in Selection.transforms)
{
Show(t);
}
s_lastHidden.Clear();
}

If I switch the menuItem above to alt-shift-h instead of just shift-h, everything is fine.

I see the validator, but I don’t really have anything decent to validate on. I want it to function unless you’re in some text edit field somewhere.

We’re on 5.4.1p3

Odd, it doesn’t work that way for me in 5.5.0b4 or 5.4.0f3 or 5.1.4p1. It shouldn’t work like that. Definitely file a bug report and a repro project. It might be just that version or something else causing it.

If you did want to validate, you could validate against what the active editor window is, or even just that your Selection is contains scene objects.

1 Like

Hello,
I have the same problem when I use: [MenuItem("Tools/DoStuff _p")]
I can’t insert a “p” inside a textbox

I use Unity 2018.2.7

This is a problem for me in 5.6.5p4, even with the validate function it suppresses typing.
This makes it a tradeoff between saving time and not being able to type certain characters.