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); } }
/// <summary> /// Käsittelee näppäimen painalluksen. /// </summary> /// <param name="key">Näppäin.</param> private void HandleKeyPress(VirtualKey key) { switch (key.Type) { case VirtualKeyType.Enter: EnterPressed?.Invoke(this, EventArgs.Empty); break; case VirtualKeyType.Backspace: BackspacePressed?.Invoke(this, EventArgs.Empty); break; case VirtualKeyType.Normal: default: InputEntered?.Invoke(this, new VirtualKeyboardInputEventArgs(key.Value)); break; } key.Pressed(); }
protected void OnBackspacePressed(KeyPressedEventArgs e) { BackspacePressed?.Invoke(this, e); }