OnSceneGui, EventType.KeyUp and Shift-Keys

Hello everyone,

I’ve a strange little problem and I hope you can help me :smile:

I’m currently writing a custom editor for my hexagon based game and I’ve implemented a custom editor which implements the OnSceneGui function.

Within that function I react to different events. One of those events is EventType.KeyUp. I’m using this to determine how to manipulate a selection of hexagon grids.

The problem is that the shift key events don’t seem to get through. The ctrl-keys get catched as intended (although I get multiple events for that key which correspond to the key-repeat).

            case EventType.KeyUp:
                if (current.keyCode == KeyCode.LeftControl || current.keyCode == KeyCode.RightControl)
                {
                    Debug.Log("Ctrl released");
                    ctrlPressed = false;
                }
                if (current.keyCode == KeyCode.LeftShift || current.keyCode == KeyCode.RightShift)
                {
                    Debug.Log("shift released");
                    shiftPressed = false;
                }

Are shift-key pressed passed to the OnSceneGui events?

having the same issue - many keys (shift, alt, caps lock, etc.) do not trigger a KeyDown or KeyUp event in OnSceneGUI. :frowning:

I don’t know precisely why these wouldn’t work for you, however the “special” keys like shift, control, command, etc… all have special boolean members within the Event.current- in this case “Event.current.shift”. Unless you’re specifically wanting behaviour that’s associated with one of the buttons and not the other, it may be best to just go with that instead.

2 Likes