unity key detection

79

unity key detection -

public static bool GetAlphaKeyValue(out int alphaKey)
{
    alphaKey = -1;

    if (Input.GetKeyDown(KeyCode.Alpha0) alphaKey = 0;
    else if (Input.GetKeyDown(KeyCode.Alpha1) alphaKey = 1;
    else if (Input.GetKeyDown(KeyCode.Alpha2) alphaKey = 2;
    else if (Input.GetKeyDown(KeyCode.Alpha3) alphaKey = 3;
    else if (Input.GetKeyDown(KeyCode.Alpha4) alphaKey = 4;
    else if (Input.GetKeyDown(KeyCode.Alpha5) alphaKey = 5;
    else if (Input.GetKeyDown(KeyCode.Alpha6) alphaKey = 6;
    else if (Input.GetKeyDown(KeyCode.Alpha7) alphaKey = 7;
    else if (Input.GetKeyDown(KeyCode.Alpha8) alphaKey = 8;
    else if (Input.GetKeyDown(KeyCode.Alpha9) alphaKey = 9;

    return alphaKey >= 0;
}

Comments

Submit
0 Comments