Example #1
0
 private void Control_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Space)
     {
         SpacePressed?.Invoke(this, EventArgs.Empty);
     }
 }
Example #2
0
 private void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space))
     {
         SpacePressed?.Invoke();
     }
     if (Input.GetKeyDown(KeyCode.LeftShift))
     {
         ShiftPressed?.Invoke();
     }
 }
Example #3
0
        private void RenderWindow_TextEntered(object sender, TextEventArgs e)
        {
            //Console.WriteLine((int)e.Unicode[0]);

            if (e.Unicode[0] >= 48 && e.Unicode[0] <= 57)
            {
                KeyPressed?.Invoke(this, new KeyPressedArgs()
                {
                    Char = e.Unicode[0]
                });
            }
            else if (e.Unicode[0] >= 65 && e.Unicode[0] <= 90)
            {
                KeyPressed?.Invoke(this, new KeyPressedArgs()
                {
                    Char = e.Unicode[0]
                });
            }
            else if (e.Unicode[0] >= 97 && e.Unicode[0] <= 122)
            {
                KeyPressed?.Invoke(this, new KeyPressedArgs()
                {
                    Char = e.Unicode[0]
                });
            }

            if (e.Unicode[0] == 8)
            {
                BackspacePressed?.Invoke(this, null);
            }

            if (e.Unicode[0] == 9)
            {
                TabulatorPressed?.Invoke(this, null);
            }

            if (e.Unicode[0] == 13)
            {
                EnterPressed?.Invoke(this, null);
            }

            if (e.Unicode[0] == 27)
            {
                EscapePressed?.Invoke(this, null);
            }

            if (e.Unicode[0] == 32)
            {
                SpacePressed?.Invoke(this, null);
            }
        }