- Home /
GetKeyDown Enter button not working
I wanted to print "Enter key pressed" when I press the enter key but it's not working.
Here's my code: (note: it's in the void Update() section)
if(Input.GetKeyDown(KeyCode.Return)) {
Debug.Log("Enter Key Pressed");
}
Your code should work and it works in my project.
I know it could sound dumb, but are you sure you have an enabled object with this script in your scene?
Do you look for the message in the right place? It should be in unity's Console panel.
Answer by EDDDDDDD · May 26, 2021 at 09:44 AM
The code is correct. Make sure you click in the game window first though after you have pressed play to run the game. You only need to do this in the unity editor once you build the game it should work fine without having to do this.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Illuminating a 3D object's edges OnMouseOver (script in c#)? 1 Answer
How to get holding key to prioritize 1 Answer