Stopping keyboard/mouse input

Is there a simple way to stop all mouse keyboard input until say spacebar is pressed (for like popping a dialog up on the screen)?

Or is the method putting a global variable somewhere and then if then check if that is true or false everytime before input?

Probably this or some variation thereof. (I don’t think there’s any way to disable input selectively, so you’ll most likely have to handle that in your own code.)