String not updating in the OnGUI loop.

So I’m trying to create some personalized text boxes here and I’m having issues getting the string defined on the object to update with the new characters.

The GUIText is working fine with integers but hitting the various keys on the keyboard detects the proper keys (tested with Debug.Log).

Any insights on this would be appreciated, here’s where the magic(or lack thereof) happens:

public class InputBox : MonoBehaviour {

	public string DahInput;
	private int i = 0;

	GUIText text;
	// Use this for initialization
	void Start () {

		DahInput = "rawr";

		text = (GUIText)(Instantiate(Resources.Load<GUIText> ("InputText")));
		//text.transform.parent = transform;
		text.alignment = TextAlignment.Right;
		//text.transform.localPosition;


	}
	void OnGUI() {
		Event e = Event.current;
		if (e.type == EventType.KeyDown)
		{
			Debug.Log("Key Pressed");
			if (e.keyCode == KeyCode.Backspace)
			{
				// delete the last character
			}
			/*else if (e.keyCode == KeyCode.XXXXX)
			{
				// implement other special key handling if you want
			}*/
			else
			{
              // THIS IS WHERE THE ERROR HAPPENS
              // doesnt work
				DahInput += e.character;
				i++;
			}
		}

		text.text = DahInput;

	}

Thanks,
Ozzadar

use EventType.KeyUp - it’ll register when the key is released but you won’t have missing/additional key presses. for normal typing, that should be ok.

you’d need to modify it to allow for repeating keys…