Gondwana Game Engine Development (master) - 2.6.1
Gondwana is a cross-platform 2.5D game and rendering engine written in C#/.NET 8. It provides fine-grained control over rendering, timing, and scene composition, with built-in support for parallax, z-ordering, pixel overhang, collision detection, and particle effects. Gondwana targets desktop and web platforms using SkiaSharp for graphics and pluggable audio backends for desktop and browser targets.
Loading...
Searching...
No Matches
KeyGesture.cs
2
4
8public readonly record struct KeyGesture
9{
13 public KeyGesture(int key, KeyboardModifierState modifiers = KeyboardModifierState.None)
14 {
15 if (key <= 0)
16 throw new ArgumentOutOfRangeException(nameof(key));
17 if ((modifiers & ~(KeyboardModifierState.Ctrl | KeyboardModifierState.Shift | KeyboardModifierState.Alt)) != 0)
18 throw new ArgumentOutOfRangeException(nameof(modifiers));
19 Key = key;
20 Modifiers = modifiers;
21 }
22
24 public int Key { get; }
30 public static KeyGesture Ctrl(int key) => new(key, KeyboardModifierState.Ctrl);
34 public static KeyGesture CtrlShift(int key) => new(key, KeyboardModifierState.Ctrl | KeyboardModifierState.Shift);
37 public override string ToString()
38 {
39 string key = Key switch
40 {
41 >= 65 and <= 90 or >= 48 and <= 57 => ((char)Key).ToString(),
42 >= 112 and <= 135 => $"F{Key - 111}",
43 8 => "Backspace",
44 9 => "Tab",
45 13 => "Enter",
46 27 => "Esc",
47 32 => "Space",
48 33 => "PageUp",
49 34 => "PageDown",
50 35 => "End",
51 36 => "Home",
52 37 => "Left",
53 38 => "Up",
54 39 => "Right",
55 40 => "Down",
56 45 => "Insert",
57 46 => "Delete",
58 _ => Key.ToString(System.Globalization.CultureInfo.InvariantCulture)
59 };
60 return (Modifiers.HasFlag(KeyboardModifierState.Ctrl) ? "Ctrl+" : "") +
61 (Modifiers.HasFlag(KeyboardModifierState.Alt) ? "Alt+" : "") +
62 (Modifiers.HasFlag(KeyboardModifierState.Shift) ? "Shift+" : "") + key;
63 }
64}
KeyboardModifierState
Represents the state of keyboard modifier keys (Shift, Ctrl, Alt) that can be pressed simultaneously ...
@ Ctrl
The Control (Ctrl) modifier key is currently pressed. This is commonly used for keyboard shortcuts an...
int Key
Gets the adapter key code.
Definition KeyGesture.cs:24
KeyboardModifierState Modifiers
Gets the exact modifier combination.
Definition KeyGesture.cs:26
static KeyGesture Ctrl(int key)
Creates a Control-key gesture.
KeyGesture(int key, KeyboardModifierState modifiers=KeyboardModifierState.None)
Creates a gesture. Letter codes should use uppercase characters.
Definition KeyGesture.cs:13
override string ToString()
Returns a display label such as Ctrl+O or Alt+F4.
Definition KeyGesture.cs:37
static KeyGesture CtrlShift(int key)
Creates a Control-Shift gesture.