GetKeyUp Problem

I’m trying to run a simple code that will print something when I press the Space Bar. I’m very new to coding, so I apologize if the answer is simple and I overlooked it. The problem is that nothing is being printed in the console when I press the Space Bar.

var MenuScreen : int = 0;

if (MenuScreen == 0) {
	if (Input.GetKeyUp(KeyCode.Space)){
	print ("Bacon");
	}
}

Any help is greatly appreciated! :slight_smile:

Debug.Log and Debug.LogError are the main log functions that you should be using, not print.

Also, make sure your script is actually a component of a gameobject in the scene.

If that doesn’t solve your issue, check to make sure there are no compiler errors.

Thanks.

The code where you check if the spacebar is pressed , is it placed within the update method of your script ?
It will likely not be registered by the script because it maybe only run once.

Try adding it to your update method/ function in the case of javascript

And also use

Debug.Log("BACON");

if you want to output something to the console

void Update()
{
if(Input.GetKeyUp(KeyCode.Space) && MenuScreen==0)
print(“Bacon”);
}