There’s an undocumented method you can implement that catches modifier key state changes called ModifierKeysChanged(). Any time the shift, ctrl, alt, win, or command keys go up or down, this method will be called.
using UnityEditor; using UnityEngine; public class ModifierKeysChangedEditorWindow : EditorWindow { private void ModifierKeysChanged() { //NOTE: Event.current is null at this point, so // it can't be used to check the state of // the modifier keys Debug.Log("Modifier keys changed"); } [MenuItem("Tools/Modifier Keys Window")] public static void Init_ToolsMenu() { EditorWindow window = EditorWindow.GetWindow<ModifierKeysChangedEditorWindow>(); window.title = "Modifier Keys"; window.Show(); } }
Underneath, the method is simply being added to EditorApplication.modifierKeysChanged automatically. This callback doesn’t pass any parameters, and Event.current is null at the time it is invoked. At this time, I can’t find any way to test which modifier key state actually changed.
A possible use-case is when the window should change somehow when shift is pressed/released, you could call Repaint() here. There are, however, other ways to handle modifier keys in an EditorWindow. You should keep in mind that this is undocumented, so it may cease to work with any Unity update in the future. As of 4.5.3p2, it works.