So what you have here is that KeyCode is a enumeration which is a type in itself separate from int although it holds a int value. So while KeyCode.Alpha1 will give you a int of value 49 , you cant pass a int directly into the Input.GeyKeyDown function itself. This is because the function GeyKeyDown has 2 versions and one of them expects a value of type string while the other one expects a value of type KeyCode. So as you see there is no version of GeyKeyDown that accepts a regular int - recall that you need to match the type of the methods parameters when passing values to it.
With the above in mind looking at your examples we see :
-
49+index - this gives a “int” which is not of type KeyCode. but KeyCode.Alpha1, Alpha2, etc are as they are declared in the enumeration. So you can only pass in a value of type KeyCode to that function not a int. But you can add a int to a Keycode value as that also gives a keycode if the sum is declared in the keycode.
-
Keycode.49 - is incorrect , there is no member declared with name “49” in the enumeration KeyCode . Also you cant have member names starting with digits so this would not be a legal/allowed name anyway.
Why use enums instead of directly using 48 or 49 etc ? Well for one thing it allows for safety. You are able to make sure the function cant be called with some invalid int value which is not a valid keycode. So if you try a Keycode.Alpha1 + 2000 it will give you a error.
Edit:
First 2 arrows show the 2 versions of GetKeyDown and arrow #3 shows the error in Visual studio when I try to check if KeyCode.Alpha1 is equal to 49 which they are not as they are different types. ie, one is of type KeyCode and the other of type int