Thanks to Bunny83’s comment I was able to figure out the proper way to do this.
You have to set a flag outside OnSceneGUI() and update the flag with the KeyDown & KeyUp event.
This would do something like this.
[CustomEditor(typeof(Test))]
public class TestInspector : Editor {
private bool bDraw;
void OnSceneGUI (){
if (Event.current.type == EventType.keyDown && Event.current.keyCode == KeyCode.H)
bDraw= true;
else if (Event.current.type == EventType.keyUp && Event.current.keyCode == KeyCode.H)
bDraw= false;
if (bDraw)
Handles.CubeCap(0, Vector3.zero, Quaternion.identity, 1);
}
}