My guess is that it's trying to input "enter" the same way you would use enter when you type something in your chat bar.
The difference is that when you type it in the chat bar, code allows it to output into the chat box see example.
But when you are to enter any name and press enter in the "Game Name" section, it's trying to figure out where to output, and eventually you would get an error is my guess, which is why it takes you back to the main game lobby because it couldn't output correctly.
This is off the top of my head coming from my experience with coding.