Can't get ENTER key working

I’ve been trying to get the Enter key working:

void Update () {
  if (Input.GetKeyDown("enter"))
  {
    print ("enter pressed");
  }
}

I also tried Input.GetKeyDown(Keycode.Return)

I read the manual and other posts, and I can get the keys working, but for the life of me I can’t get Enter working.

1 Answer

1

Always use KeyCode rather than strings. You can see the list of keys in the docs, specifically KeyCode.Return (not Keycode). Unless you’re talking about the numeric keypad enter key, which is KeyCode.KeypadEnter.