I don\'t want to use if statement. For simplicity and performance I want to use switch case and execute that method. I want all the keyboard Input to get detected. But is there
You may use Input.inputString to catch the keyboard input entered in the last frame as a string.
void Update()
{
//get the input
var input = Input.inputString;
//ignore null input to avoid unnecessary computation
if (!string.IsNullOrEmpty(input))
//logic related to the char pressed
Debug.Log("Pressed char: " + Input.inputString);
}
Foreach Loop
You might use foreach loop approach, like suggested in other answers, but it is not as performant. Foreach allocates more memory and must check against all possible keys (it is also less readable).
If you do not care about time and memory performance, then you might follow this answer. It uses the foreach loop approach and create a reusable interface.
OnGUI
Finally you could catch the Event.current (that is a unityGUI Event), like explained in this answer, but doing so you would rely on the OnGUI method. This method has the worst performance.