Camfight.Form1.LoginInputControl C# (CSharp) Method

LoginInputControl() private method

private LoginInputControl ( KeyEventArgs e ) : void
e System.Windows.Forms.KeyEventArgs
return void
        private void LoginInputControl(KeyEventArgs e)
        {
            if (e.KeyData == Keys.Up)
            {
                logIndex = 0;
            }
            else if (e.KeyData == Keys.Down)
            {
                logIndex = 1;
            }
            else if (e.KeyValue>=65 && e.KeyValue<=90)
            {
                if (logIndex == 0 && username.Length<12)
                    username += e.KeyData.ToString();
                else if(logIndex==1 && password.Length<12)
                    password += e.KeyData.ToString();
            }
            else if (e.KeyValue >= 48 && e.KeyValue <= 57)
            {
                if (logIndex == 0 && username.Length < 12)
                    username += (e.KeyValue-48).ToString();
                else if (logIndex == 1 && password.Length < 12)
                    password += (e.KeyValue-48).ToString();
            }
            else if (e.KeyData == Keys.Back)
            {
                if (logIndex == 0 && username.Length != 0)
                    username = username.Substring(0, username.Length - 1);
                else if (logIndex == 1 && password.Length != 0)
                    password = password.Substring(0, password.Length - 1);
            }
            else if (e.KeyData == Keys.Enter)
            {
                if (username != null && password != null && username != "" && password != "")
                {
                    ConnectToServer();
                    if(listenthr!=null) gamestate = GameState.LOADING;
                }
            }
        }