How to disable the Tab key event?

When I press “Tab” on my keyboard, Unity automatically cycle through all the GUI.TextField and set focus to them. I do not want this and would like to get rid of the functionality. Is there any way to do this?

I try to do like this:

if( Event.current.keyCode == KeyCode.Tab )
{
    Event.current.Use();
}

But this doesn’t work. If anyone know about this problem, please help. Thanks!

There is something weird in the code of text fields, this does work:

string s1 = string.Empty, s2 = string.Empty, s3 = string.Empty;
void OnGUI()
{
	if (Event.current.keyCode == KeyCode.Tab || Event.current.character == '\t')
		Event.current.Use();

	s1 = GUI.TextField(new Rect(0,0,100,20), s1);
	s2 = GUI.TextField(new Rect(0, 30, 100, 20), s2);
	s3 = GUI.TextField(new Rect(0, 60, 100, 20), s3);
}
2 Likes

Oh,It’s really work! Thank you “rytis”.