1 using Microsoft.Xna.Framework;
2 using Microsoft.Xna.Framework.Input;
8 public long RepeatCount => Param & 0xffff;
9 public bool ExtendedKey => (Param & (1 << 24)) > 0;
10 public bool AltPressed => (Param & (1 << 29)) > 0;
11 public bool PreviousState => (Param & (1 << 30)) > 0;
12 public bool TransitionState => (Param & (1 << 31)) > 0;
15 public readonly record
struct KeyEventArgs(Keys KeyCode, char Character);
44 static bool initialized;
50 public static void Initialize(GameWindow window)
57 window.TextInput += ReceiveInput;
58 window.KeyDown += ReceiveKeyDown;
59 window.TextEditing += ReceiveTextEditing;
64 private static void ReceiveInput(
object sender, TextInputEventArgs e)
66 OnCharEntered(e.Character);
69 private static void ReceiveKeyDown(
object sender, TextInputEventArgs e)
71 KeyDown?.Invoke(sender,
new KeyEventArgs(e.Key, e.Character));
74 private static void ReceiveTextEditing(
object sender, TextEditingEventArgs e)
76 EditingText?.Invoke(sender, e);
79 public static void OnCharEntered(
char character)