I'm actually using Blender 2.77 while reading Game Development with Blender.

In an example it's being used the string "quit\n" in an expression controller to make the user press the sequence of keys: q u i t ENTER to exit the game ones it's started.

I've tested the logic and everything seems fine, but the escape sequences, indeed as an example if I set the string to be "quit" only as I press the sequence q u i t the game quits.

The book I'm reading is been written for use with Blender 2.66 so things may have changed since then.

What I'm asking is how do I make the BGE interpret "\n" as the in-game RETURN key pressure in my expression?

Link to the file:



2 Answers 2


CR is no printable character. The keyboard logger does not do anything with it (tested in 2.76).

Better use the (measured by a separate keyboard sensor) as event to evaluate whatever the keyboard logging already measured.

Typically on such an event, you:

  • evaluate whatever was entered
  • clear the log buffer
  • process whatever the evaluation resulted on

This also means you do not need to evaluate while entering the string (but you still can).

Here is a demo: enter image description here

logging: logs printable keyboard input to property "Text"

evaluate: input confirmed on CR

help: evaluate if "help" was entered

toggle help: send a message "toggle help" when help was requested

reset input: clears the input field, allowing to enter a new phrase

I hope it helps


I've tried to apply the answers got, but experimenting a bit this morning I've found a very simple solution to my problem. What I was looking for was a logic asking me to enter the sequence of keys q u i t ENTER to make the game quit. Since I'm still at the 96th page of my book things will probably get more complex, thus the simpler I stay the better it is.

Here is a pic of the logic enter image description here

Specifically to my case an even simpler logic would be enter image description here


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .