GUI.TextField focus kills Input.GetKeyDown on Mac but not on PC

Hi,
The code below behaves differently on a Mac than on a PC. I think this might be since Unity3.

The problem is that on a Mac, I do not get Input.anyKeyDown or Input.GetKeyDown once the Textfield has focus.

The reason I want to do this is so that I can detect if the enter or arrow keys are pressed while a chat window is open and automatically send or close the window, and return to navigation mode.

I had some look at events. I think I could detect a return this way but not arrows.

Is there another way to do this and is this a bug that I should report?

using UnityEngine;
using System.Collections;

public class KeyFocusTest : MonoBehaviour {

	// Use this for initialization
    public string myText = "Set focus here";

    void OnGUI()
    { 
        myText = GUI.TextField( new Rect( 0,0, 300, 300 ), myText );
 
    }
	
	
	// Update is called once per frame
	void Update ()
    {
        if (Input.anyKeyDown)
        { 
            Debug.Log("anyKeyDown!");
        }

        if (Input.GetKeyDown(KeyCode.Return))
        {
            Debug.Log("GetKeyDown:Return!");
        }

        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            Debug.Log("GetKeyDown:LeftArrow!");
        }
	
    }
}

There have been other similar issues with MonoDevelop but it appears this particular problem doesn’t have an entry in the bug database. Please can you file a bug report for it (menu: Help > Report A Bug).

I am having the same problem. Is there a workaround for this?

Same issue for me with Unity 3.1:
TextFields on focus override the feed of the input from the keyboard.
Actually I am trying only with Mac OSX, currently I do not know about this behaviour under Windows.
Thanks.

In 3.4, Unity will always eat the keypress if focus is textfield. To check for a specific keypress, use

if (Event.current.type == EventType.KeyDown  Event.current.character == '\n')
   DoWhatEverNewLineShouldDo ();

Inside your OnGUI

Is there a way to use this to check if the ESC key has been pressed?

okay nm… i found the answer: Event.current.keyCode

Has anyone had this problem with Linux. I have a Linux user telling me textfields are not eating keypress. (when he is using the in game chat, he’s still running and things)