How to make HMD go black (unity VR; HTC Vive)?

I’m working on a project in which I want the HMD to go black at certain points. For example, player presses button on controller and the HMD goes black, that is, they can’t see anything anymore. Then, upon pressing the button again, the screen goes back to the perspective of the user. How does one make the screen go black with code?

Thanks!

You should be able to add a canvas on which you put a panel where you change the color to black. Then you create a script where you reference this panel and set the panel to enabled on a GetButtonDown event and disabled on a GetButtonUp event. Depending on your code, you can also instead use GetKeyDown and GetKeyUp.

Make sure that your panel is at the top of your canvas or other canvas elements can peak through