The easiest way I've found to toggle anything on/off is by creating a variable and then use the following string to set it: Set variable to 1-variablename. What it does is if the variable is equal to 0 then 1-0=1 so it will switch it to 1. If the variable is 1 then 1-1=0 which switches it to 0.
So in your example.
On key pressed > Set variable HUD to 1-HUD
If variable HUD = 0 > Make objects invisible
else > Make Objects visible