Bläddra i källkod

Fixes #3071 & #3079. Key cast and static props are not correct (#3089)

* Removed char->Key cast. Added Key(char)

* Re-added char->key cast. Added unit tests

* Fixed standard keys to always return new instead of being readonly

* Re-fixed WindowsDriver to report shift/alt/ctrl as key/down/up

* Re-fixed WindowsDriver to report shift/alt/ctrl as key/down/up

* Adds string constructor to Key + tests.

* Simplified Key json

* Added string/Key cast operators.
Tig 1 år sedan
förälder
incheckning
80ef4b5e19

+ 7 - 1
Terminal.Gui/Configuration/ConfigurationManager.cs

@@ -9,6 +9,7 @@ using System.IO;
 using System.Linq;
 using System.Linq;
 using System.Reflection;
 using System.Reflection;
 using System.Text;
 using System.Text;
+using System.Text.Encodings.Web;
 using System.Text.Json;
 using System.Text.Json;
 using System.Text.Json.Serialization;
 using System.Text.Json.Serialization;
 using static Terminal.Gui.SpinnerStyle;
 using static Terminal.Gui.SpinnerStyle;
@@ -70,8 +71,13 @@ public static partial class ConfigurationManager {
 				// We override the standard Rune converter to support specifying Glyphs in
 				// We override the standard Rune converter to support specifying Glyphs in
 				// a flexible way
 				// a flexible way
 				new RuneJsonConverter(),
 				new RuneJsonConverter(),
+				// Override Key to support "Ctrl+Q" format.
+				new KeyJsonConverter()
 			},
 			},
-	};
+		// Enables Key to be "Ctrl+Q" vs "Ctrl\u002BQ"
+		Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
+
+};
 
 
 	/// <summary>
 	/// <summary>
 	/// A dictionary of all properties in the Terminal.Gui project that are decorated with the <see cref="SerializableConfigurationProperty"/> attribute.
 	/// A dictionary of all properties in the Terminal.Gui project that are decorated with the <see cref="SerializableConfigurationProperty"/> attribute.

+ 7 - 41
Terminal.Gui/Configuration/KeyJsonConverter.cs

@@ -3,46 +3,12 @@ using System.Text.Json;
 using System.Text.Json.Serialization;
 using System.Text.Json.Serialization;
 
 
 namespace Terminal.Gui;
 namespace Terminal.Gui;
-class KeyJsonConverter : JsonConverter<Key> {
-	
-	public override Key Read (ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
-	{
-		if (reader.TokenType == JsonTokenType.StartObject) {
-			Key key = Key.Empty;
-			while (reader.Read ()) {
-				if (reader.TokenType == JsonTokenType.EndObject) {
-					break;
-				}
 
 
-				if (reader.TokenType == JsonTokenType.PropertyName) {
-					string propertyName = reader.GetString ();
-					reader.Read ();
+/// <summary>
+/// Support for <see cref="Key"/> in JSON in the form of "Ctrl-X" or "Alt-Shift-F1".
+/// </summary>
+public class KeyJsonConverter : JsonConverter<Key> {
+	public override Key Read (ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => Key.TryParse (reader.GetString (), out var key) ? key : Key.Empty;
 
 
-					switch (propertyName?.ToLowerInvariant ()) {
-					case "key":
-						if (reader.TokenType == JsonTokenType.String) {
-							string keyValue = reader.GetString ();
-							if (Key.TryParse (keyValue, out key)) {
-								break;
-							}
-							throw new JsonException ($"Error parsing Key: {keyValue}.");
-
-						}
-						break;
-					default:
-						throw new JsonException ($"Unexpected Key property \"{propertyName}\".");
-					}
-				}
-			}
-			return key;
-		}
-		throw new JsonException ($"Unexpected StartObject token when parsing Key: {reader.TokenType}.");
-	}
-
-	public override void Write (Utf8JsonWriter writer, Key value, JsonSerializerOptions options)
-	{
-		writer.WriteStartObject ();
-		writer.WriteString ("Key", value.ToString ());
-		writer.WriteEndObject ();
-	}
-}
+	public override void Write (Utf8JsonWriter writer, Key value, JsonSerializerOptions options) => writer.WriteStringValue (value.ToString ());
+}

+ 28 - 29
Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs

@@ -649,7 +649,6 @@ public enum CursorVisibility {
 /// Lowercase alpha keys are encoded as values between 65 and 90 corresponding to the un-shifted A to Z keys on a keyboard. Enum values
 /// Lowercase alpha keys are encoded as values between 65 and 90 corresponding to the un-shifted A to Z keys on a keyboard. Enum values
 /// are provided for these (e.g. <see cref="KeyCode.A"/>, <see cref="KeyCode.B"/>, etc.). Even though the values are the same as the ASCII
 /// are provided for these (e.g. <see cref="KeyCode.A"/>, <see cref="KeyCode.B"/>, etc.). Even though the values are the same as the ASCII
 /// values for uppercase characters, these enum values represent *lowercase*, un-shifted characters.
 /// values for uppercase characters, these enum values represent *lowercase*, un-shifted characters.
-/// TODO: Strongly consider renaming these from .A to .Z to .A_Lowercase to .Z_Lowercase (or .a to .z).
 /// </para>
 /// </para>
 /// <para>
 /// <para>
 /// Numeric keys are the values between 48 and 57 corresponding to 0 to 9 (e.g. <see cref="KeyCode.D0"/>, <see cref="KeyCode.D1"/>, etc.).
 /// Numeric keys are the values between 48 and 57 corresponding to 0 to 9 (e.g. <see cref="KeyCode.D0"/>, <see cref="KeyCode.D1"/>, etc.).
@@ -680,7 +679,7 @@ public enum KeyCode : uint {
 
 
 	/// <summary>
 	/// <summary>
 	/// If the <see cref="SpecialMask"/> is set, then the value is that of the special mask,
 	/// If the <see cref="SpecialMask"/> is set, then the value is that of the special mask,
-	/// otherwise, the value is the one of the lower bits (as extracted by <see cref="CharMask"/>).
+	/// otherwise, the value is in the the lower bits (as extracted by <see cref="CharMask"/>).
 	/// </summary>
 	/// </summary>
 	SpecialMask = 0xfff00000,
 	SpecialMask = 0xfff00000,
 
 
@@ -791,111 +790,111 @@ public enum KeyCode : uint {
 	D9,
 	D9,
 
 
 	/// <summary>
 	/// <summary>
-	/// The key code for the user pressing Shift-A
+	/// The key code for the A key
 	/// </summary>
 	/// </summary>
 	A = 65,
 	A = 65,
 	/// <summary>
 	/// <summary>
-	/// The key code for the user pressing Shift-B
+	/// The key code for the B key
 	/// </summary>
 	/// </summary>
 	B,
 	B,
 	/// <summary>
 	/// <summary>
-	/// The key code for the user pressing Shift-C
+	/// The key code for the C key
 	/// </summary>
 	/// </summary>
 	C,
 	C,
 	/// <summary>
 	/// <summary>
-	/// The key code for the user pressing Shift-D
+	/// The key code for the D key
 	/// </summary>
 	/// </summary>
 	D,
 	D,
 	/// <summary>
 	/// <summary>
-	/// The key code for the user pressing Shift-E
+	/// The key code for the E key
 	/// </summary>
 	/// </summary>
 	E,
 	E,
 	/// <summary>
 	/// <summary>
-	/// The key code for the user pressing Shift-F
+	/// The key code for the F key
 	/// </summary>
 	/// </summary>
 	F,
 	F,
 	/// <summary>
 	/// <summary>
-	/// The key code for the user pressing Shift-G
+	/// The key code for the G key
 	/// </summary>
 	/// </summary>
 	G,
 	G,
 	/// <summary>
 	/// <summary>
-	/// The key code for the user pressing Shift-H
+	/// The key code for the H key
 	/// </summary>
 	/// </summary>
 	H,
 	H,
 	/// <summary>
 	/// <summary>
-	/// The key code for the user pressing Shift-I
+	/// The key code for the I key
 	/// </summary>
 	/// </summary>
 	I,
 	I,
 	/// <summary>
 	/// <summary>
-	/// The key code for the user pressing Shift-J
+	/// The key code for the J key
 	/// </summary>
 	/// </summary>
 	J,
 	J,
 	/// <summary>
 	/// <summary>
-	/// The key code for the user pressing Shift-K
+	/// The key code for the K key
 	/// </summary>
 	/// </summary>
 	K,
 	K,
 	/// <summary>
 	/// <summary>
-	/// The key code for the user pressing Shift-L
+	/// The key code for the L key
 	/// </summary>
 	/// </summary>
 	L,
 	L,
 	/// <summary>
 	/// <summary>
-	/// The key code for the user pressing Shift-M
+	/// The key code for the M key
 	/// </summary>
 	/// </summary>
 	M,
 	M,
 	/// <summary>
 	/// <summary>
-	/// The key code for the user pressing Shift-N
+	/// The key code for the N key
 	/// </summary>
 	/// </summary>
 	N,
 	N,
 	/// <summary>
 	/// <summary>
-	/// The key code for the user pressing Shift-O
+	/// The key code for the O key
 	/// </summary>
 	/// </summary>
 	O,
 	O,
 	/// <summary>
 	/// <summary>
-	/// The key code for the user pressing Shift-P
+	/// The key code for the P key
 	/// </summary>
 	/// </summary>
 	P,
 	P,
 	/// <summary>
 	/// <summary>
-	/// The key code for the user pressing Shift-Q
+	/// The key code for the Q key
 	/// </summary>
 	/// </summary>
 	Q,
 	Q,
 	/// <summary>
 	/// <summary>
-	/// The key code for the user pressing Shift-R
+	/// The key code for the R key
 	/// </summary>
 	/// </summary>
 	R,
 	R,
 	/// <summary>
 	/// <summary>
-	/// The key code for the user pressing Shift-S
+	/// The key code for the S key
 	/// </summary>
 	/// </summary>
 	S,
 	S,
 	/// <summary>
 	/// <summary>
-	/// The key code for the user pressing Shift-T
+	/// The key code for the T key
 	/// </summary>
 	/// </summary>
 	T,
 	T,
 	/// <summary>
 	/// <summary>
-	/// The key code for the user pressing Shift-U
+	/// The key code for the U key
 	/// </summary>
 	/// </summary>
 	U,
 	U,
 	/// <summary>
 	/// <summary>
-	/// The key code for the user pressing Shift-V
+	/// The key code for the V key
 	/// </summary>
 	/// </summary>
 	V,
 	V,
 	/// <summary>
 	/// <summary>
-	/// The key code for the user pressing Shift-W
+	/// The key code for the W key
 	/// </summary>
 	/// </summary>
 	W,
 	W,
 	/// <summary>
 	/// <summary>
-	/// The key code for the user pressing Shift-X
+	/// The key code for the X key
 	/// </summary>
 	/// </summary>
 	X,
 	X,
 	/// <summary>
 	/// <summary>
-	/// The key code for the user pressing Shift-Y
+	/// The key code for the Y key
 	/// </summary>
 	/// </summary>
 	Y,
 	Y,
 	/// <summary>
 	/// <summary>
-	/// The key code for the user pressing Shift-Z
+	/// The key code for the Z key
 	/// </summary>
 	/// </summary>
 	Z,
 	Z,
 	/// <summary>
 	/// <summary>
-	/// The key code for the user pressing A
+	/// The key code for the Delete key.
 	/// </summary>
 	/// </summary>
 	Delete = 127,
 	Delete = 127,
 
 

+ 4 - 3
Terminal.Gui/ConsoleDrivers/WindowsDriver.cs

@@ -1051,16 +1051,17 @@ internal class WindowsDriver : ConsoleDriver {
 			return (KeyCode)((uint)KeyCode.F1 + delta);
 			return (KeyCode)((uint)KeyCode.F1 + delta);
 		}
 		}
 
 
+		// If the key is JUST a modifier, return it as that key
 		if (key == (ConsoleKey)16) { // Shift
 		if (key == (ConsoleKey)16) { // Shift
-			return KeyCode.Null | KeyCode.ShiftMask;
+			return KeyCode.ShiftKey;
 		}
 		}
 
 
 		if (key == (ConsoleKey)17) { // Ctrl
 		if (key == (ConsoleKey)17) { // Ctrl
-			return KeyCode.Null | KeyCode.CtrlMask;
+			return KeyCode.CtrlKey;
 		}
 		}
 
 
 		if (key == (ConsoleKey)18) { // Alt
 		if (key == (ConsoleKey)18) { // Alt
-			return KeyCode.Null | KeyCode.AltMask;
+			return KeyCode.AltKey;
 		}
 		}
 
 
 		return ConsoleKeyMapping.MapKeyModifiers (keyInfo, (KeyCode)((uint)keyInfo.KeyChar));
 		return ConsoleKeyMapping.MapKeyModifiers (keyInfo, (KeyCode)((uint)keyInfo.KeyChar));

+ 164 - 94
Terminal.Gui/Input/Key.cs

@@ -4,6 +4,7 @@ using System.Diagnostics.CodeAnalysis;
 using System.Linq;
 using System.Linq;
 using System.Text;
 using System.Text;
 using System.Text.Json.Serialization;
 using System.Text.Json.Serialization;
+using static System.Runtime.CompilerServices.RuntimeHelpers;
 
 
 namespace Terminal.Gui;
 namespace Terminal.Gui;
 
 
@@ -64,7 +65,6 @@ namespace Terminal.Gui;
 /// </list>
 /// </list>
 /// </para>
 /// </para>
 /// </remarks>
 /// </remarks>
-[JsonConverter (typeof (KeyJsonConverter))]
 public class Key : EventArgs, IEquatable<Key> {
 public class Key : EventArgs, IEquatable<Key> {
 	/// <summary>
 	/// <summary>
 	/// Constructs a new <see cref="Key"/>
 	/// Constructs a new <see cref="Key"/>
@@ -72,11 +72,56 @@ public class Key : EventArgs, IEquatable<Key> {
 	public Key () : this (KeyCode.Null) { }
 	public Key () : this (KeyCode.Null) { }
 
 
 	/// <summary>
 	/// <summary>
-	///   Constructs a new <see cref="Key"/> from the provided Key value
+	/// Constructs a new <see cref="Key"/> from the provided Key value
 	/// </summary>
 	/// </summary>
 	/// <param name="k">The key</param>
 	/// <param name="k">The key</param>
 	public Key (KeyCode k) => KeyCode = k;
 	public Key (KeyCode k) => KeyCode = k;
 
 
+	/// <summary>
+	/// Constructs a new <see cref="Key"/> from a char.
+	/// </summary>
+	/// <remarks>
+	/// <para>
+	/// The key codes for the A..Z keys are encoded as values between 65 and 90 (<see cref="KeyCode.A"/> through <see cref="KeyCode.Z"/>).
+	/// While these are the same as the ASCII values for uppercase characters, they represent *keys*, not characters.
+	/// Therefore, this constructor will store 'A'..'Z' as <see cref="KeyCode.A"/>..<see cref="KeyCode.Z"/> with the
+	/// <see cref="KeyCode.ShiftMask"/> set and will
+	/// store `a`..`z` as <see cref="KeyCode.A"/>..<see cref="KeyCode.Z"/>.
+	/// </para>
+	/// </remarks>
+	/// <param name="ch"></param>
+	public Key (char ch)
+	{
+		switch (ch) {
+		case >= 'A' and <= 'Z':
+			// Upper case A..Z mean "Shift-char" so we need to add Shift
+			KeyCode = (KeyCode)ch | KeyCode.ShiftMask;
+			break;
+		case >= 'a' and <= 'z':
+			// Lower case a..z mean no shift, so we need to store as Key.A...Key.Z
+			KeyCode = (KeyCode)(ch - 32);
+			return;
+		default:
+			KeyCode = (KeyCode)ch;
+			break;
+		}
+	}
+
+	/// <summary>
+	/// Constructs a new Key from a string describing the key.
+	/// See <see cref="TryParse(string, out Terminal.Gui.Key)"/> for information
+	/// on the format of the string.
+	/// </summary>
+	/// <param name="str">The string describing the key.</param>
+	public Key (string str)
+	{
+		var result = Key.TryParse (str, out Key key);
+		if (!result) {
+			throw new ArgumentException (@$"Invalid key string: {str}", nameof (str));
+		}
+		KeyCode = key.KeyCode;
+	}
+
 	/// <summary>
 	/// <summary>
 	/// Indicates if the current Key event has already been processed and the driver should stop notifying any other event subscriber.
 	/// Indicates if the current Key event has already been processed and the driver should stop notifying any other event subscriber.
 	/// Its important to set this value to true specially when updating any View's layout from inside the subscriber method.
 	/// Its important to set this value to true specially when updating any View's layout from inside the subscriber method.
@@ -94,7 +139,6 @@ public class Key : EventArgs, IEquatable<Key> {
 	/// <remarks>
 	/// <remarks>
 	/// This property is the backing data for the <see cref="Key"/>. It is a <see cref="KeyCode"/> enum value.
 	/// This property is the backing data for the <see cref="Key"/>. It is a <see cref="KeyCode"/> enum value.
 	/// </remarks>
 	/// </remarks>
-	[JsonInclude] [JsonConverter (typeof (KeyCodeJsonConverter))]
 	public KeyCode KeyCode { get; init; }
 	public KeyCode KeyCode { get; init; }
 
 
 	/// <summary>
 	/// <summary>
@@ -106,8 +150,11 @@ public class Key : EventArgs, IEquatable<Key> {
 	/// The key value as a Rune. This is the actual value of the key pressed, and is independent of the modifiers.
 	/// The key value as a Rune. This is the actual value of the key pressed, and is independent of the modifiers.
 	/// </summary>
 	/// </summary>
 	/// <remarks>
 	/// <remarks>
-	/// If the key pressed is a letter (a-z or A-Z), this will be the upper or lower case letter depending on whether the shift key is pressed.
-	/// If the key is outside of the <see cref="KeyCode.CharMask"/> range, this will be <see langword="default"/>.
+	/// <para>
+	/// If the key is a letter (a-z or A-Z), the Rune be the upper or lower case letter depending on whether
+	/// the shift key was pressed.
+	/// If the key is outside of the <see cref="KeyCode.CharMask"/> range, the returned Rune will be <see langword="default"/>.
+	/// </para>
 	/// </remarks>
 	/// </remarks>
 	public Rune AsRune => ToRune (KeyCode);
 	public Rune AsRune => ToRune (KeyCode);
 
 
@@ -115,11 +162,14 @@ public class Key : EventArgs, IEquatable<Key> {
 	/// Converts a <see cref="KeyCode"/> to a <see cref="Rune"/>.
 	/// Converts a <see cref="KeyCode"/> to a <see cref="Rune"/>.
 	/// </summary>
 	/// </summary>
 	/// <remarks>
 	/// <remarks>
-	/// If the key is a letter (a-z or A-Z), this will be the upper or lower case letter depending on whether the shift key is pressed.
-	/// If the key is outside of the <see cref="KeyCode.CharMask"/> range, this will be <see langword="default"/>.
+	/// <para>
+	/// If the key is a letter (a-z or A-Z), the Rune be the upper or lower case letter depending on whether
+	/// the shift key was pressed.
+	/// If the key is outside of the <see cref="KeyCode.CharMask"/> range, the returned Rune will be <see langword="default"/>.
+	/// </para>
 	/// </remarks>
 	/// </remarks>
 	/// <param name="key"></param>
 	/// <param name="key"></param>
-	/// <returns>The key converted to a rune. <see langword="default"/> if conversion is not possible.</returns>
+	/// <returns>The key converted to a Rune. <see langword="default"/> if conversion is not possible.</returns>
 	public static Rune ToRune (KeyCode key)
 	public static Rune ToRune (KeyCode key)
 	{
 	{
 		if (key is KeyCode.Null or KeyCode.SpecialMask || key.HasFlag (KeyCode.CtrlMask) || key.HasFlag (KeyCode.AltMask)) {
 		if (key is KeyCode.Null or KeyCode.SpecialMask || key.HasFlag (KeyCode.CtrlMask) || key.HasFlag (KeyCode.AltMask)) {
@@ -277,14 +327,34 @@ public class Key : EventArgs, IEquatable<Key> {
 	/// Cast <see cref="KeyCode"/> to a <see cref="Key"/>. 
 	/// Cast <see cref="KeyCode"/> to a <see cref="Key"/>. 
 	/// </summary>
 	/// </summary>
 	/// <param name="keyCode"></param>
 	/// <param name="keyCode"></param>
-	public static implicit operator Key (KeyCode keyCode) => new (keyCode);
-
+	public static implicit operator Key (KeyCode keyCode) => new Key (keyCode);
 
 
 	/// <summary>
 	/// <summary>
 	/// Cast <see langword="char"/> to a <see cref="Key"/>. 
 	/// Cast <see langword="char"/> to a <see cref="Key"/>. 
 	/// </summary>
 	/// </summary>
+	/// <remarks>
+	/// See <see cref="Key(char)"/> for more information.
+	/// </remarks>
 	/// <param name="ch"></param>
 	/// <param name="ch"></param>
-	public static implicit operator Key (char ch) => new ((KeyCode)ch);
+	public static implicit operator Key (char ch) => new Key (ch);
+
+	/// <summary>
+	/// Cast <see langword="string"/> to a <see cref="Key"/>. 
+	/// </summary>
+	/// <remarks>
+	/// See <see cref="Key(string)"/> for more information.
+	/// </remarks>
+	/// <param name="str"></param>
+	public static implicit operator Key (string str) => new Key (str);
+
+	/// <summary>
+	/// Cast a <see cref="Key"/> to a <see langword="string"/>. 
+	/// </summary>
+	/// <remarks>
+	/// See <see cref="Key(string)"/> for more information.
+	/// </remarks>
+	/// <param name="key"></param>
+	public static implicit operator string (Key key) => key.ToString ();
 
 
 	/// <inheritdoc/>
 	/// <inheritdoc/>
 	public override bool Equals (object obj) => obj is Key k && k.KeyCode == KeyCode;
 	public override bool Equals (object obj) => obj is Key k && k.KeyCode == KeyCode;
@@ -563,416 +633,416 @@ public class Key : EventArgs, IEquatable<Key> {
 	/// <summary>
 	/// <summary>
 	/// An uninitialized The <see cref="Key"/> object.
 	/// An uninitialized The <see cref="Key"/> object.
 	/// </summary>
 	/// </summary>
-	public new static readonly Key Empty = new ();
+	public new static Key Empty => new ();
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the Backspace key.
 	/// The <see cref="Key"/> object for the Backspace key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key Backspace = new (KeyCode.Backspace);
+	public static Key Backspace => new (KeyCode.Backspace);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the tab key (forwards tab key).
 	/// The <see cref="Key"/> object for the tab key (forwards tab key).
 	/// </summary>
 	/// </summary>
-	public static readonly Key Tab = new (KeyCode.Tab);
+	public static Key Tab => new (KeyCode.Tab);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the return key.
 	/// The <see cref="Key"/> object for the return key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key Enter = new (KeyCode.Enter);
+	public static Key Enter => new (KeyCode.Enter);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the clear key.
 	/// The <see cref="Key"/> object for the clear key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key Clear = new (KeyCode.Clear);
+	public static Key Clear => new (KeyCode.Clear);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the Shift key.
 	/// The <see cref="Key"/> object for the Shift key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key Shift = new (KeyCode.ShiftKey);
+	public static Key Shift => new (KeyCode.ShiftKey);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the Ctrl key.
 	/// The <see cref="Key"/> object for the Ctrl key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key Ctrl = new (KeyCode.CtrlKey);
+	public static Key Ctrl => new (KeyCode.CtrlKey);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the Alt key.
 	/// The <see cref="Key"/> object for the Alt key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key Alt = new (KeyCode.AltKey);
+	public static Key Alt => new (KeyCode.AltKey);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the CapsLock key.
 	/// The <see cref="Key"/> object for the CapsLock key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key CapsLock = new (KeyCode.CapsLock);
+	public static Key CapsLock => new (KeyCode.CapsLock);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the Escape key.
 	/// The <see cref="Key"/> object for the Escape key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key Esc = new (KeyCode.Esc);
+	public static Key Esc => new (KeyCode.Esc);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the Space bar key.
 	/// The <see cref="Key"/> object for the Space bar key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key Space = new (KeyCode.Space);
+	public static Key Space => new (KeyCode.Space);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for 0 key.
 	/// The <see cref="Key"/> object for 0 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key D0 = new (KeyCode.D0);
+	public static Key D0 => new (KeyCode.D0);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for 1 key.
 	/// The <see cref="Key"/> object for 1 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key D1 = new (KeyCode.D1);
+	public static Key D1 => new (KeyCode.D1);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for 2 key.
 	/// The <see cref="Key"/> object for 2 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key D2 = new (KeyCode.D2);
+	public static Key D2 => new (KeyCode.D2);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for 3 key.
 	/// The <see cref="Key"/> object for 3 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key D3 = new (KeyCode.D3);
+	public static Key D3 => new (KeyCode.D3);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for 4 key.
 	/// The <see cref="Key"/> object for 4 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key D4 = new (KeyCode.D4);
+	public static Key D4 => new (KeyCode.D4);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for 5 key.
 	/// The <see cref="Key"/> object for 5 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key D5 = new (KeyCode.D5);
+	public static Key D5 => new (KeyCode.D5);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for 6 key.
 	/// The <see cref="Key"/> object for 6 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key D6 = new (KeyCode.D6);
+	public static Key D6 => new (KeyCode.D6);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for 7 key.
 	/// The <see cref="Key"/> object for 7 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key D7 = new (KeyCode.D7);
+	public static Key D7 => new (KeyCode.D7);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for 8 key.
 	/// The <see cref="Key"/> object for 8 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key D8 = new (KeyCode.D8);
+	public static Key D8 => new (KeyCode.D8);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for 9 key.
 	/// The <see cref="Key"/> object for 9 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key D9 = new (KeyCode.D9);
+	public static Key D9 => new (KeyCode.D9);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the A key (un-shifted). Use <c>Key.A.WithShift</c> for uppercase 'A'.
 	/// The <see cref="Key"/> object for the A key (un-shifted). Use <c>Key.A.WithShift</c> for uppercase 'A'.
 	/// </summary>
 	/// </summary>
-	public static readonly Key A = new (KeyCode.A);
+	public static Key A => new (KeyCode.A);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the B key (un-shifted). Use <c>Key.B.WithShift</c> for uppercase 'B'.
 	/// The <see cref="Key"/> object for the B key (un-shifted). Use <c>Key.B.WithShift</c> for uppercase 'B'.
 	/// </summary>
 	/// </summary>
-	public static readonly Key B = new (KeyCode.B);
+	public static Key B => new (KeyCode.B);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the C key (un-shifted). Use <c>Key.C.WithShift</c> for uppercase 'C'.
 	/// The <see cref="Key"/> object for the C key (un-shifted). Use <c>Key.C.WithShift</c> for uppercase 'C'.
 	/// </summary>
 	/// </summary>
-	public static readonly Key C = new (KeyCode.C);
+	public static Key C => new (KeyCode.C);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the D key (un-shifted). Use <c>Key.D.WithShift</c> for uppercase 'D'.
 	/// The <see cref="Key"/> object for the D key (un-shifted). Use <c>Key.D.WithShift</c> for uppercase 'D'.
 	/// </summary>
 	/// </summary>
-	public static readonly Key D = new (KeyCode.D);
+	public static Key D => new (KeyCode.D);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the E key (un-shifted). Use <c>Key.E.WithShift</c> for uppercase 'E'.
 	/// The <see cref="Key"/> object for the E key (un-shifted). Use <c>Key.E.WithShift</c> for uppercase 'E'.
 	/// </summary>
 	/// </summary>
-	public static readonly Key E = new (KeyCode.E);
+	public static Key E => new (KeyCode.E);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the F key (un-shifted). Use <c>Key.F.WithShift</c> for uppercase 'F'.
 	/// The <see cref="Key"/> object for the F key (un-shifted). Use <c>Key.F.WithShift</c> for uppercase 'F'.
 	/// </summary>
 	/// </summary>
-	public static readonly Key F = new (KeyCode.F);
+	public static Key F => new (KeyCode.F);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the G key (un-shifted). Use <c>Key.G.WithShift</c> for uppercase 'G'.
 	/// The <see cref="Key"/> object for the G key (un-shifted). Use <c>Key.G.WithShift</c> for uppercase 'G'.
 	/// </summary>
 	/// </summary>
-	public static readonly Key G = new (KeyCode.G);
+	public static Key G => new (KeyCode.G);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the H key (un-shifted). Use <c>Key.H.WithShift</c> for uppercase 'H'.
 	/// The <see cref="Key"/> object for the H key (un-shifted). Use <c>Key.H.WithShift</c> for uppercase 'H'.
 	/// </summary>
 	/// </summary>
-	public static readonly Key H = new (KeyCode.H);
+	public static Key H => new (KeyCode.H);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the I key (un-shifted). Use <c>Key.I.WithShift</c> for uppercase 'I'.
 	/// The <see cref="Key"/> object for the I key (un-shifted). Use <c>Key.I.WithShift</c> for uppercase 'I'.
 	/// </summary>
 	/// </summary>
-	public static readonly Key I = new (KeyCode.I);
+	public static Key I => new (KeyCode.I);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the J key (un-shifted). Use <c>Key.J.WithShift</c> for uppercase 'J'.
 	/// The <see cref="Key"/> object for the J key (un-shifted). Use <c>Key.J.WithShift</c> for uppercase 'J'.
 	/// </summary>
 	/// </summary>
-	public static readonly Key J = new (KeyCode.J);
+	public static Key J => new (KeyCode.J);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the K key (un-shifted). Use <c>Key.K.WithShift</c> for uppercase 'K'.
 	/// The <see cref="Key"/> object for the K key (un-shifted). Use <c>Key.K.WithShift</c> for uppercase 'K'.
 	/// </summary>
 	/// </summary>
-	public static readonly Key K = new (KeyCode.K);
+	public static Key K => new (KeyCode.K);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the L key (un-shifted). Use <c>Key.L.WithShift</c> for uppercase 'L'.
 	/// The <see cref="Key"/> object for the L key (un-shifted). Use <c>Key.L.WithShift</c> for uppercase 'L'.
 	/// </summary>
 	/// </summary>
-	public static readonly Key L = new (KeyCode.L);
+	public static Key L => new (KeyCode.L);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the M key (un-shifted). Use <c>Key.M.WithShift</c> for uppercase 'M'.
 	/// The <see cref="Key"/> object for the M key (un-shifted). Use <c>Key.M.WithShift</c> for uppercase 'M'.
 	/// </summary>
 	/// </summary>
-	public static readonly Key M = new (KeyCode.M);
+	public static Key M => new (KeyCode.M);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the N key (un-shifted). Use <c>Key.N.WithShift</c> for uppercase 'N'.
 	/// The <see cref="Key"/> object for the N key (un-shifted). Use <c>Key.N.WithShift</c> for uppercase 'N'.
 	/// </summary>
 	/// </summary>
-	public static readonly Key N = new (KeyCode.N);
+	public static Key N => new (KeyCode.N);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the O key (un-shifted). Use <c>Key.O.WithShift</c> for uppercase 'O'.
 	/// The <see cref="Key"/> object for the O key (un-shifted). Use <c>Key.O.WithShift</c> for uppercase 'O'.
 	/// </summary>
 	/// </summary>
-	public static readonly Key O = new (KeyCode.O);
+	public static Key O => new (KeyCode.O);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the P key (un-shifted). Use <c>Key.P.WithShift</c> for uppercase 'P'.
 	/// The <see cref="Key"/> object for the P key (un-shifted). Use <c>Key.P.WithShift</c> for uppercase 'P'.
 	/// </summary>
 	/// </summary>
-	public static readonly Key P = new (KeyCode.P);
+	public static Key P => new (KeyCode.P);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the Q key (un-shifted). Use <c>Key.Q.WithShift</c> for uppercase 'Q'.
 	/// The <see cref="Key"/> object for the Q key (un-shifted). Use <c>Key.Q.WithShift</c> for uppercase 'Q'.
 	/// </summary>
 	/// </summary>
-	public static readonly Key Q = new (KeyCode.Q);
+	public static Key Q => new (KeyCode.Q);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the R key (un-shifted). Use <c>Key.R.WithShift</c> for uppercase 'R'.
 	/// The <see cref="Key"/> object for the R key (un-shifted). Use <c>Key.R.WithShift</c> for uppercase 'R'.
 	/// </summary>
 	/// </summary>
-	public static readonly Key R = new (KeyCode.R);
+	public static Key R => new (KeyCode.R);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the S key (un-shifted). Use <c>Key.S.WithShift</c> for uppercase 'S'.
 	/// The <see cref="Key"/> object for the S key (un-shifted). Use <c>Key.S.WithShift</c> for uppercase 'S'.
 	/// </summary>
 	/// </summary>
-	public static readonly Key S = new (KeyCode.S);
+	public static Key S => new (KeyCode.S);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the T key (un-shifted). Use <c>Key.T.WithShift</c> for uppercase 'T'.
 	/// The <see cref="Key"/> object for the T key (un-shifted). Use <c>Key.T.WithShift</c> for uppercase 'T'.
 	/// </summary>
 	/// </summary>
-	public static readonly Key T = new (KeyCode.T);
+	public static Key T => new (KeyCode.T);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the U key (un-shifted). Use <c>Key.U.WithShift</c> for uppercase 'U'.
 	/// The <see cref="Key"/> object for the U key (un-shifted). Use <c>Key.U.WithShift</c> for uppercase 'U'.
 	/// </summary>
 	/// </summary>
-	public static readonly Key U = new (KeyCode.U);
+	public static Key U => new (KeyCode.U);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the V key (un-shifted). Use <c>Key.V.WithShift</c> for uppercase 'V'.
 	/// The <see cref="Key"/> object for the V key (un-shifted). Use <c>Key.V.WithShift</c> for uppercase 'V'.
 	/// </summary>
 	/// </summary>
-	public static readonly Key V = new (KeyCode.V);
+	public static Key V => new (KeyCode.V);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the W key (un-shifted). Use <c>Key.W.WithShift</c> for uppercase 'W'.
 	/// The <see cref="Key"/> object for the W key (un-shifted). Use <c>Key.W.WithShift</c> for uppercase 'W'.
 	/// </summary>
 	/// </summary>
-	public static readonly Key W = new (KeyCode.W);
+	public static Key W => new (KeyCode.W);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the X key (un-shifted). Use <c>Key.X.WithShift</c> for uppercase 'X'.
 	/// The <see cref="Key"/> object for the X key (un-shifted). Use <c>Key.X.WithShift</c> for uppercase 'X'.
 	/// </summary>
 	/// </summary>
-	public static readonly Key X = new (KeyCode.X);
+	public static Key X => new (KeyCode.X);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the Y key (un-shifted). Use <c>Key.Y.WithShift</c> for uppercase 'Y'.
 	/// The <see cref="Key"/> object for the Y key (un-shifted). Use <c>Key.Y.WithShift</c> for uppercase 'Y'.
 	/// </summary>
 	/// </summary>
-	public static readonly Key Y = new (KeyCode.Y);
+	public static Key Y => new (KeyCode.Y);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the Z key (un-shifted). Use <c>Key.Z.WithShift</c> for uppercase 'Z'.
 	/// The <see cref="Key"/> object for the Z key (un-shifted). Use <c>Key.Z.WithShift</c> for uppercase 'Z'.
 	/// </summary>
 	/// </summary>
-	public static readonly Key Z = new (KeyCode.Z);
+	public static Key Z => new (KeyCode.Z);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the Delete key.
 	/// The <see cref="Key"/> object for the Delete key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key Delete = new (KeyCode.Delete);
+	public static Key Delete => new (KeyCode.Delete);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for the Cursor up key.
 	/// The <see cref="Key"/> object for the Cursor up key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key CursorUp = new (KeyCode.CursorUp);
+	public static Key CursorUp => new (KeyCode.CursorUp);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for Cursor down key.
 	/// The <see cref="Key"/> object for Cursor down key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key CursorDown = new (KeyCode.CursorDown);
+	public static Key CursorDown => new (KeyCode.CursorDown);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for Cursor left key.
 	/// The <see cref="Key"/> object for Cursor left key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key CursorLeft = new (KeyCode.CursorLeft);
+	public static Key CursorLeft => new (KeyCode.CursorLeft);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for Cursor right key.
 	/// The <see cref="Key"/> object for Cursor right key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key CursorRight = new (KeyCode.CursorRight);
+	public static Key CursorRight => new (KeyCode.CursorRight);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for Page Up key.
 	/// The <see cref="Key"/> object for Page Up key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key PageUp = new (KeyCode.PageUp);
+	public static Key PageUp => new (KeyCode.PageUp);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for Page Down key.
 	/// The <see cref="Key"/> object for Page Down key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key PageDown = new (KeyCode.PageDown);
+	public static Key PageDown => new (KeyCode.PageDown);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for Home key.
 	/// The <see cref="Key"/> object for Home key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key Home = new (KeyCode.Home);
+	public static Key Home => new (KeyCode.Home);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for End key.
 	/// The <see cref="Key"/> object for End key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key End = new (KeyCode.End);
+	public static Key End => new (KeyCode.End);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for Insert Character key.
 	/// The <see cref="Key"/> object for Insert Character key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key InsertChar = new (KeyCode.InsertChar);
+	public static Key InsertChar => new (KeyCode.InsertChar);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for Delete Character key.
 	/// The <see cref="Key"/> object for Delete Character key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key DeleteChar = new (KeyCode.DeleteChar);
+	public static Key DeleteChar => new (KeyCode.DeleteChar);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for Print Screen key.
 	/// The <see cref="Key"/> object for Print Screen key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key PrintScreen = new (KeyCode.PrintScreen);
+	public static Key PrintScreen => new (KeyCode.PrintScreen);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for F1 key.
 	/// The <see cref="Key"/> object for F1 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key F1 = new (KeyCode.F1);
+	public static Key F1 => new (KeyCode.F1);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for F2 key.
 	/// The <see cref="Key"/> object for F2 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key F2 = new (KeyCode.F2);
+	public static Key F2 => new (KeyCode.F2);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for F3 key.
 	/// The <see cref="Key"/> object for F3 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key F3 = new (KeyCode.F3);
+	public static Key F3 => new (KeyCode.F3);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for F4 key.
 	/// The <see cref="Key"/> object for F4 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key F4 = new (KeyCode.F4);
+	public static Key F4 => new (KeyCode.F4);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for F5 key.
 	/// The <see cref="Key"/> object for F5 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key F5 = new (KeyCode.F5);
+	public static Key F5 => new (KeyCode.F5);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for F6 key.
 	/// The <see cref="Key"/> object for F6 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key F6 = new (KeyCode.F6);
+	public static Key F6 => new (KeyCode.F6);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for F7 key.
 	/// The <see cref="Key"/> object for F7 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key F7 = new (KeyCode.F7);
+	public static Key F7 => new (KeyCode.F7);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for F8 key.
 	/// The <see cref="Key"/> object for F8 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key F8 = new (KeyCode.F8);
+	public static Key F8 => new (KeyCode.F8);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for F9 key.
 	/// The <see cref="Key"/> object for F9 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key F9 = new (KeyCode.F9);
+	public static Key F9 => new (KeyCode.F9);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for F10 key.
 	/// The <see cref="Key"/> object for F10 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key F10 = new (KeyCode.F10);
+	public static Key F10 => new (KeyCode.F10);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for F11 key.
 	/// The <see cref="Key"/> object for F11 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key F11 = new (KeyCode.F11);
+	public static Key F11 => new (KeyCode.F11);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for F12 key.
 	/// The <see cref="Key"/> object for F12 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key F12 = new (KeyCode.F12);
+	public static Key F12 => new (KeyCode.F12);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for F13 key.
 	/// The <see cref="Key"/> object for F13 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key F13 = new (KeyCode.F13);
+	public static Key F13 => new (KeyCode.F13);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for F14 key.
 	/// The <see cref="Key"/> object for F14 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key F14 = new (KeyCode.F14);
+	public static Key F14 => new (KeyCode.F14);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for F15 key.
 	/// The <see cref="Key"/> object for F15 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key F15 = new (KeyCode.F15);
+	public static Key F15 => new (KeyCode.F15);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for F16 key.
 	/// The <see cref="Key"/> object for F16 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key F16 = new (KeyCode.F16);
+	public static Key F16 => new (KeyCode.F16);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for F17 key.
 	/// The <see cref="Key"/> object for F17 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key F17 = new (KeyCode.F17);
+	public static Key F17 => new (KeyCode.F17);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for F18 key.
 	/// The <see cref="Key"/> object for F18 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key F18 = new (KeyCode.F18);
+	public static Key F18 => new (KeyCode.F18);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for F19 key.
 	/// The <see cref="Key"/> object for F19 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key F19 = new (KeyCode.F19);
+	public static Key F19 => new (KeyCode.F19);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for F20 key.
 	/// The <see cref="Key"/> object for F20 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key F20 = new (KeyCode.F20);
+	public static Key F20 => new (KeyCode.F20);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for F21 key.
 	/// The <see cref="Key"/> object for F21 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key F21 = new (KeyCode.F21);
+	public static Key F21 => new (KeyCode.F21);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for F22 key.
 	/// The <see cref="Key"/> object for F22 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key F22 = new (KeyCode.F22);
+	public static Key F22 => new (KeyCode.F22);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for F23 key.
 	/// The <see cref="Key"/> object for F23 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key F23 = new (KeyCode.F23);
+	public static Key F23 => new (KeyCode.F23);
 
 
 	/// <summary>
 	/// <summary>
 	/// The <see cref="Key"/> object for F24 key.
 	/// The <see cref="Key"/> object for F24 key.
 	/// </summary>
 	/// </summary>
-	public static readonly Key F24 = new (KeyCode.F24);
+	public static Key F24 => new (KeyCode.F24);
 	#endregion
 	#endregion
 }
 }

+ 3 - 9
Terminal.Gui/Resources/config.json

@@ -16,15 +16,9 @@
   // to throw exceptions. 
   // to throw exceptions. 
   "ConfigurationManager.ThrowOnJsonErrors": false,
   "ConfigurationManager.ThrowOnJsonErrors": false,
 
 
-  "Application.AlternateBackwardKey": {
-    "Key": "Ctrl+PageUp"
-  },
-  "Application.AlternateForwardKey": {
-    "Key": "Ctrl+PageDown"
-  },
-  "Application.QuitKey": {
-    "Key": "Ctrl+Q"
-  },
+  "Application.AlternateBackwardKey": "Ctrl+PageUp",
+  "Application.AlternateForwardKey": "Ctrl+PageDown",
+  "Application.QuitKey": "Ctrl+Q",
   "Application.IsMouseDisabled": false,
   "Application.IsMouseDisabled": false,
   "Theme": "Default",
   "Theme": "Default",
   "Themes": [
   "Themes": [

+ 1 - 3
UICatalog/Resources/config.json

@@ -1,8 +1,6 @@
 {
 {
   "$schema": "https://gui-cs.github.io/Terminal.Gui/schemas/tui-config-schema.json",
   "$schema": "https://gui-cs.github.io/Terminal.Gui/schemas/tui-config-schema.json",
-  "Application.QuitKey": {
-    "Key": "Esc"
-  },
+  "Application.QuitKey": "Esc",
   "FileDialog.MaxSearchResults": 10000,
   "FileDialog.MaxSearchResults": 10000,
   "FileDialogStyle.DefaultUseColors": false,
   "FileDialogStyle.DefaultUseColors": false,
   "FileDialogStyle.DefaultUseUnicodeCharacters": false,
   "FileDialogStyle.DefaultUseUnicodeCharacters": false,

+ 4 - 4
UICatalog/UICatalog.cs

@@ -516,7 +516,7 @@ class UICatalogApp {
 			miIsMenuBorderDisabled = new MenuItem {
 			miIsMenuBorderDisabled = new MenuItem {
 				Title = "Disable Menu _Border"
 				Title = "Disable Menu _Border"
 			};
 			};
-			miIsMenuBorderDisabled.Shortcut = (KeyCode)((Key)miIsMenuBorderDisabled!.Title!.Substring (14, 1) [0]).WithAlt.WithCtrl;
+			miIsMenuBorderDisabled.Shortcut = (KeyCode)(new Key (miIsMenuBorderDisabled!.Title!.Substring (14, 1) [0])).WithAlt.WithCtrl;
 			miIsMenuBorderDisabled.CheckType |= MenuItemCheckStyle.Checked;
 			miIsMenuBorderDisabled.CheckType |= MenuItemCheckStyle.Checked;
 			miIsMenuBorderDisabled.Action += () => {
 			miIsMenuBorderDisabled.Action += () => {
 				miIsMenuBorderDisabled.Checked = (bool)!miIsMenuBorderDisabled.Checked!;
 				miIsMenuBorderDisabled.Checked = (bool)!miIsMenuBorderDisabled.Checked!;
@@ -553,7 +553,7 @@ class UICatalogApp {
 			miIsMouseDisabled = new MenuItem {
 			miIsMouseDisabled = new MenuItem {
 				Title = "_Disable Mouse"
 				Title = "_Disable Mouse"
 			};
 			};
-			miIsMouseDisabled.Shortcut = (KeyCode)((Key)miIsMouseDisabled!.Title!.Substring (1, 1) [0]).WithAlt.WithCtrl;
+			miIsMouseDisabled.Shortcut = (KeyCode)(new Key (miIsMouseDisabled!.Title!.Substring (1, 1) [0])).WithAlt.WithCtrl;
 			miIsMouseDisabled.CheckType |= MenuItemCheckStyle.Checked;
 			miIsMouseDisabled.CheckType |= MenuItemCheckStyle.Checked;
 			miIsMouseDisabled.Action += () => {
 			miIsMouseDisabled.Action += () => {
 				miIsMouseDisabled.Checked = Application.IsMouseDisabled = (bool)!miIsMouseDisabled.Checked!;
 				miIsMouseDisabled.Checked = Application.IsMouseDisabled = (bool)!miIsMouseDisabled.Checked!;
@@ -592,7 +592,7 @@ class UICatalogApp {
 			foreach (Enum diag in Enum.GetValues (_diagnosticFlags.GetType ())) {
 			foreach (Enum diag in Enum.GetValues (_diagnosticFlags.GetType ())) {
 				var item = new MenuItem {
 				var item = new MenuItem {
 					Title = GetDiagnosticsTitle (diag),
 					Title = GetDiagnosticsTitle (diag),
-					Shortcut = (KeyCode)((Key)index.ToString () [0]).WithAlt
+					Shortcut = (KeyCode)(new Key(index.ToString () [0])).WithAlt
 				};
 				};
 				index++;
 				index++;
 				item.CheckType |= MenuItemCheckStyle.Checked;
 				item.CheckType |= MenuItemCheckStyle.Checked;
@@ -685,7 +685,7 @@ class UICatalogApp {
 			foreach (var theme in Themes!) {
 			foreach (var theme in Themes!) {
 				var item = new MenuItem {
 				var item = new MenuItem {
 					Title = $"_{theme.Key}",
 					Title = $"_{theme.Key}",
-					Shortcut = (KeyCode)((Key)((int)KeyCode.D1 + schemeCount++)).WithCtrl
+					Shortcut = (KeyCode)(new Key ((KeyCode)((uint)KeyCode.D1 + (schemeCount++))).WithCtrl)
 				};
 				};
 				item.CheckType |= MenuItemCheckStyle.Checked;
 				item.CheckType |= MenuItemCheckStyle.Checked;
 				item.Checked = theme.Key == _cachedTheme; // CM.Themes.Theme;
 				item.Checked = theme.Key == _cachedTheme; // CM.Themes.Theme;

+ 470 - 474
UnitTests/Configuration/ConfigurationMangerTests.cs

@@ -7,359 +7,357 @@ using System.Text.Json;
 using Xunit;
 using Xunit;
 using static Terminal.Gui.ConfigurationManager;
 using static Terminal.Gui.ConfigurationManager;
 
 
-namespace Terminal.Gui.ConfigurationTests {
-	public class ConfigurationManagerTests {
+namespace Terminal.Gui.ConfigurationTests; 
 
 
-		public static readonly JsonSerializerOptions _jsonOptions = new () {
-			Converters = {
-				new AttributeJsonConverter (),
-				new ColorJsonConverter (),
-				}
-		};
-
-		[Fact ()]
-		public void DeepMemberwiseCopyTest ()
-		{
-			// Value types
-			var stringDest = "Destination";
-			var stringSrc = "Source";
-			var stringCopy = DeepMemberwiseCopy (stringSrc, stringDest);
-			Assert.Equal (stringSrc, stringCopy);
-
-			stringDest = "Destination";
-			stringSrc = "Destination";
-			stringCopy = DeepMemberwiseCopy (stringSrc, stringDest);
-			Assert.Equal (stringSrc, stringCopy);
-
-			stringDest = "Destination";
-			stringSrc = null;
-			stringCopy = DeepMemberwiseCopy (stringSrc, stringDest);
-			Assert.Equal (stringSrc, stringCopy);
-
-			stringDest = "Destination";
-			stringSrc = string.Empty;
-			stringCopy = DeepMemberwiseCopy (stringSrc, stringDest);
-			Assert.Equal (stringSrc, stringCopy);
-
-			var boolDest = true;
-			var boolSrc = false;
-			var boolCopy = DeepMemberwiseCopy (boolSrc, boolDest);
-			Assert.Equal (boolSrc, boolCopy);
-
-			boolDest = false;
-			boolSrc = true;
-			boolCopy = DeepMemberwiseCopy (boolSrc, boolDest);
-			Assert.Equal (boolSrc, boolCopy);
-
-			boolDest = true;
-			boolSrc = true;
-			boolCopy = DeepMemberwiseCopy (boolSrc, boolDest);
-			Assert.Equal (boolSrc, boolCopy);
-
-			boolDest = false;
-			boolSrc = false;
-			boolCopy = DeepMemberwiseCopy (boolSrc, boolDest);
-			Assert.Equal (boolSrc, boolCopy);
-
-			// Structs
-			var attrDest = new Attribute (Color.Black);
-			var attrSrc = new Attribute (Color.White);
-			var attrCopy = DeepMemberwiseCopy (attrSrc, attrDest);
-			Assert.Equal (attrSrc, attrCopy);
-
-			// Classes
-			var colorschemeDest = new ColorScheme () { Disabled = new Attribute (Color.Black) };
-			var colorschemeSrc = new ColorScheme () { Disabled = new Attribute (Color.White) };
-			var colorschemeCopy = DeepMemberwiseCopy (colorschemeSrc, colorschemeDest);
-			Assert.Equal (colorschemeSrc, colorschemeCopy);
-
-			// Dictionaries
-			var dictDest = new Dictionary<string, Attribute> () { { "Disabled", new Attribute (Color.Black) } };
-			var dictSrc = new Dictionary<string, Attribute> () { { "Disabled", new Attribute (Color.White) } };
-			var dictCopy = (Dictionary<string, Attribute>)DeepMemberwiseCopy (dictSrc, dictDest);
-			Assert.Equal (dictSrc, dictCopy);
-
-			dictDest = new Dictionary<string, Attribute> () { { "Disabled", new Attribute (Color.Black) } };
-			dictSrc = new Dictionary<string, Attribute> () { { "Disabled", new Attribute (Color.White) }, { "Normal", new Attribute (Color.Blue) } };
-			dictCopy = (Dictionary<string, Attribute>)DeepMemberwiseCopy (dictSrc, dictDest);
-			Assert.Equal (dictSrc, dictCopy);
-
-			// src adds an item
-			dictDest = new Dictionary<string, Attribute> () { { "Disabled", new Attribute (Color.Black) } };
-			dictSrc = new Dictionary<string, Attribute> () { { "Disabled", new Attribute (Color.White) }, { "Normal", new Attribute (Color.Blue) } };
-			dictCopy = (Dictionary<string, Attribute>)DeepMemberwiseCopy (dictSrc, dictDest);
-			Assert.Equal (2, dictCopy.Count);
-			Assert.Equal (dictSrc ["Disabled"], dictCopy ["Disabled"]);
-			Assert.Equal (dictSrc ["Normal"], dictCopy ["Normal"]);
-
-			// src updates only one item
-			dictDest = new Dictionary<string, Attribute> () { { "Disabled", new Attribute (Color.Black) }, { "Normal", new Attribute (Color.White) } };
-			dictSrc = new Dictionary<string, Attribute> () { { "Disabled", new Attribute (Color.White) } };
-			dictCopy = (Dictionary<string, Attribute>)DeepMemberwiseCopy (dictSrc, dictDest);
-			Assert.Equal (2, dictCopy.Count);
-			Assert.Equal (dictSrc ["Disabled"], dictCopy ["Disabled"]);
-			Assert.Equal (dictDest ["Normal"], dictCopy ["Normal"]);
-		}
-
-		//[Fact ()]
-		//public void LoadFromJsonTest ()
-		//{
-		//	Assert.True (false, "This test needs an implementation");
-		//}
-
-		//[Fact ()]
-		//public void ToJsonTest ()
-		//{
-		//	Assert.True (false, "This test needs an implementation");
-		//}
-
-		//[Fact ()]
-		//public void UpdateConfigurationTest ()
-		//{
-		//	Assert.True (false, "This test needs an implementation");
-		//}
-
-		//[Fact ()]
-		//public void UpdateConfigurationFromFileTest ()
-		//{
-		//	Assert.True (false, "This test needs an implementation");
-		//}
-
-		//[Fact ()]
-		//public void SaveHardCodedDefaultsTest ()
-		//{
-		//	Assert.True (false, "This test needs an implementation");
-		//}
-
-		//[Fact ()]
-		//public void LoadGlobalFromLibraryResourceTest ()
-		//{
-		//	Assert.True (false, "This test needs an implementation");
-		//}
-
-		//[Fact ()]
-		//public void LoadGlobalFromAppDirectoryTest ()
-		//{
-		//	Assert.True (false, "This test needs an implementation");
-		//}
-
-		//[Fact ()]
-		//public void LoadGlobalFromHomeDirectoryTest ()
-		//{
-		//	Assert.True (false, "This test needs an implementation");
-		//}
-
-		//[Fact ()]
-		//public void LoadAppFromAppResourcesTest ()
-		//{
-		//	Assert.True (false, "This test needs an implementation");
-		//}
-
-		//[Fact ()]
-		//public void LoadAppFromAppDirectoryTest ()
-		//{
-		//	Assert.True (false, "This test needs an implementation");
-		//}
-
-		//[Fact ()]
-		//public void LoadAppFromHomeDirectoryTest ()
-		//{
-		//	Assert.True (false, "This test needs an implementation");
-		//}
-
-		//[Fact ()]
-		//public void LoadTest ()
-		//{
-		//	Assert.True (false, "This test needs an implementation");
-		//}
-
-		/// <summary>
-		/// Save the `config.json` file; this can be used to update the file in `Terminal.Gui.Resources.config.json'.
-		/// </summary>
-		/// <remarks>
-		/// IMPORTANT: For the file generated to be valid, this must be the ONLY test run. Config Properties
-		/// are all static and thus can be overwritten by other tests.</remarks>
-		[Fact]
-		public void SaveDefaults ()
-		{
-			ConfigurationManager.Initialize ();
-			ConfigurationManager.Reset ();
-
-			// Get the hard coded settings
-			ConfigurationManager.GetHardCodedDefaults ();
-
-			// Serialize to a JSON string
-			string json = ConfigurationManager.ToJson ();
-
-			// Write the JSON string to the file 
-			File.WriteAllText ("config.json", json);
-		}
-
-		[Fact]
-		public void UseWithoutResetAsserts ()
-		{
-			ConfigurationManager.Initialize ();
-			Assert.Throws<InvalidOperationException> (() => _ = ConfigurationManager.Settings);
-		}
-
-		[Fact]
-		public void Reset_Resets ()
-		{
-			ConfigurationManager.Locations = ConfigLocations.DefaultOnly;
-			ConfigurationManager.Reset ();
-			Assert.NotEmpty (ConfigurationManager.Themes);
-			Assert.Equal ("Default", ConfigurationManager.Themes.Theme);
+public class ConfigurationManagerTests {
+	public static readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions {
+		Converters = {
+			new AttributeJsonConverter (),
+			new ColorJsonConverter ()
 		}
 		}
+	};
+
+	[Fact ()]
+	public void DeepMemberwiseCopyTest ()
+	{
+		// Value types
+		string stringDest = "Destination";
+		string stringSrc = "Source";
+		object stringCopy = DeepMemberwiseCopy (stringSrc, stringDest);
+		Assert.Equal (stringSrc, stringCopy);
+
+		stringDest = "Destination";
+		stringSrc = "Destination";
+		stringCopy = DeepMemberwiseCopy (stringSrc, stringDest);
+		Assert.Equal (stringSrc, stringCopy);
+
+		stringDest = "Destination";
+		stringSrc = null;
+		stringCopy = DeepMemberwiseCopy (stringSrc, stringDest);
+		Assert.Equal (stringSrc, stringCopy);
+
+		stringDest = "Destination";
+		stringSrc = string.Empty;
+		stringCopy = DeepMemberwiseCopy (stringSrc, stringDest);
+		Assert.Equal (stringSrc, stringCopy);
+
+		bool boolDest = true;
+		bool boolSrc = false;
+		object boolCopy = DeepMemberwiseCopy (boolSrc, boolDest);
+		Assert.Equal (boolSrc, boolCopy);
+
+		boolDest = false;
+		boolSrc = true;
+		boolCopy = DeepMemberwiseCopy (boolSrc, boolDest);
+		Assert.Equal (boolSrc, boolCopy);
+
+		boolDest = true;
+		boolSrc = true;
+		boolCopy = DeepMemberwiseCopy (boolSrc, boolDest);
+		Assert.Equal (boolSrc, boolCopy);
+
+		boolDest = false;
+		boolSrc = false;
+		boolCopy = DeepMemberwiseCopy (boolSrc, boolDest);
+		Assert.Equal (boolSrc, boolCopy);
+
+		// Structs
+		var attrDest = new Attribute (Color.Black);
+		var attrSrc = new Attribute (Color.White);
+		object attrCopy = DeepMemberwiseCopy (attrSrc, attrDest);
+		Assert.Equal (attrSrc, attrCopy);
+
+		// Classes
+		var colorschemeDest = new ColorScheme () { Disabled = new Attribute (Color.Black) };
+		var colorschemeSrc = new ColorScheme () { Disabled = new Attribute (Color.White) };
+		object colorschemeCopy = DeepMemberwiseCopy (colorschemeSrc, colorschemeDest);
+		Assert.Equal (colorschemeSrc, colorschemeCopy);
+
+		// Dictionaries
+		var dictDest = new Dictionary<string, Attribute> () { { "Disabled", new Attribute (Color.Black) } };
+		var dictSrc = new Dictionary<string, Attribute> () { { "Disabled", new Attribute (Color.White) } };
+		var dictCopy = (Dictionary<string, Attribute>)DeepMemberwiseCopy (dictSrc, dictDest);
+		Assert.Equal (dictSrc, dictCopy);
+
+		dictDest = new Dictionary<string, Attribute> () { { "Disabled", new Attribute (Color.Black) } };
+		dictSrc = new Dictionary<string, Attribute> () { { "Disabled", new Attribute (Color.White) }, { "Normal", new Attribute (Color.Blue) } };
+		dictCopy = (Dictionary<string, Attribute>)DeepMemberwiseCopy (dictSrc, dictDest);
+		Assert.Equal (dictSrc, dictCopy);
+
+		// src adds an item
+		dictDest = new Dictionary<string, Attribute> () { { "Disabled", new Attribute (Color.Black) } };
+		dictSrc = new Dictionary<string, Attribute> () { { "Disabled", new Attribute (Color.White) }, { "Normal", new Attribute (Color.Blue) } };
+		dictCopy = (Dictionary<string, Attribute>)DeepMemberwiseCopy (dictSrc, dictDest);
+		Assert.Equal (2, dictCopy.Count);
+		Assert.Equal (dictSrc ["Disabled"], dictCopy ["Disabled"]);
+		Assert.Equal (dictSrc ["Normal"], dictCopy ["Normal"]);
+
+		// src updates only one item
+		dictDest = new Dictionary<string, Attribute> () { { "Disabled", new Attribute (Color.Black) }, { "Normal", new Attribute (Color.White) } };
+		dictSrc = new Dictionary<string, Attribute> () { { "Disabled", new Attribute (Color.White) } };
+		dictCopy = (Dictionary<string, Attribute>)DeepMemberwiseCopy (dictSrc, dictDest);
+		Assert.Equal (2, dictCopy.Count);
+		Assert.Equal (dictSrc ["Disabled"], dictCopy ["Disabled"]);
+		Assert.Equal (dictDest ["Normal"], dictCopy ["Normal"]);
+	}
 
 
-		[Fact]
-		public void Reset_and_ResetLoadWithLibraryResourcesOnly_are_same ()
-		{
-			ConfigurationManager.Locations = ConfigLocations.DefaultOnly;
-			// arrange
-			ConfigurationManager.Reset ();
-			ConfigurationManager.Settings ["Application.QuitKey"].PropertyValue = new Key (KeyCode.Q);
-			ConfigurationManager.Settings ["Application.AlternateForwardKey"].PropertyValue = new Key (KeyCode.F);
-			ConfigurationManager.Settings ["Application.AlternateBackwardKey"].PropertyValue = new Key (KeyCode.B);
-			ConfigurationManager.Settings ["Application.IsMouseDisabled"].PropertyValue = true;
-			ConfigurationManager.Settings.Apply ();
-
-			// assert apply worked
-			Assert.Equal (KeyCode.Q, Application.QuitKey.KeyCode);
-			Assert.Equal (KeyCode.F, Application.AlternateForwardKey.KeyCode);
-			Assert.Equal (KeyCode.B, Application.AlternateBackwardKey.KeyCode);
-			Assert.True (Application.IsMouseDisabled);
+	//[Fact ()]
+	//public void LoadFromJsonTest ()
+	//{
+	//	Assert.True (false, "This test needs an implementation");
+	//}
+
+	//[Fact ()]
+	//public void ToJsonTest ()
+	//{
+	//	Assert.True (false, "This test needs an implementation");
+	//}
+
+	//[Fact ()]
+	//public void UpdateConfigurationTest ()
+	//{
+	//	Assert.True (false, "This test needs an implementation");
+	//}
+
+	//[Fact ()]
+	//public void UpdateConfigurationFromFileTest ()
+	//{
+	//	Assert.True (false, "This test needs an implementation");
+	//}
+
+	//[Fact ()]
+	//public void SaveHardCodedDefaultsTest ()
+	//{
+	//	Assert.True (false, "This test needs an implementation");
+	//}
+
+	//[Fact ()]
+	//public void LoadGlobalFromLibraryResourceTest ()
+	//{
+	//	Assert.True (false, "This test needs an implementation");
+	//}
+
+	//[Fact ()]
+	//public void LoadGlobalFromAppDirectoryTest ()
+	//{
+	//	Assert.True (false, "This test needs an implementation");
+	//}
+
+	//[Fact ()]
+	//public void LoadGlobalFromHomeDirectoryTest ()
+	//{
+	//	Assert.True (false, "This test needs an implementation");
+	//}
+
+	//[Fact ()]
+	//public void LoadAppFromAppResourcesTest ()
+	//{
+	//	Assert.True (false, "This test needs an implementation");
+	//}
+
+	//[Fact ()]
+	//public void LoadAppFromAppDirectoryTest ()
+	//{
+	//	Assert.True (false, "This test needs an implementation");
+	//}
+
+	//[Fact ()]
+	//public void LoadAppFromHomeDirectoryTest ()
+	//{
+	//	Assert.True (false, "This test needs an implementation");
+	//}
+
+	//[Fact ()]
+	//public void LoadTest ()
+	//{
+	//	Assert.True (false, "This test needs an implementation");
+	//}
+
+	/// <summary>
+	/// Save the `config.json` file; this can be used to update the file in `Terminal.Gui.Resources.config.json'.
+	/// </summary>
+	/// <remarks>
+	/// IMPORTANT: For the file generated to be valid, this must be the ONLY test run. Config Properties
+	/// are all static and thus can be overwritten by other tests.</remarks>
+	[Fact]
+	public void SaveDefaults ()
+	{
+		Initialize ();
+		Reset ();
+
+		// Get the hard coded settings
+		GetHardCodedDefaults ();
+
+		// Serialize to a JSON string
+		string json = ToJson ();
+
+		// Write the JSON string to the file 
+		File.WriteAllText ("config.json", json);
+	}
 
 
-			//act
-			ConfigurationManager.Reset ();
+	[Fact]
+	public void UseWithoutResetAsserts ()
+	{
+		Initialize ();
+		Assert.Throws<InvalidOperationException> (() => _ = Settings);
+	}
 
 
-			// assert
-			Assert.NotEmpty (ConfigurationManager.Themes);
-			Assert.Equal ("Default", ConfigurationManager.Themes.Theme);
-			Assert.Equal (KeyCode.Q | KeyCode.CtrlMask, Application.QuitKey.KeyCode);
-			Assert.Equal (KeyCode.PageDown | KeyCode.CtrlMask, Application.AlternateForwardKey.KeyCode);
-			Assert.Equal (KeyCode.PageUp | KeyCode.CtrlMask, Application.AlternateBackwardKey.KeyCode);
-			Assert.False (Application.IsMouseDisabled);
-
-			// arrange
-			ConfigurationManager.Settings ["Application.QuitKey"].PropertyValue = new Key (KeyCode.Q);
-			ConfigurationManager.Settings ["Application.AlternateForwardKey"].PropertyValue = new Key (KeyCode.F);
-			ConfigurationManager.Settings ["Application.AlternateBackwardKey"].PropertyValue = new Key (KeyCode.B);
-			ConfigurationManager.Settings ["Application.IsMouseDisabled"].PropertyValue = true;
-			ConfigurationManager.Settings.Apply ();
-
-			ConfigurationManager.Locations = ConfigLocations.DefaultOnly;
-
-			// act
-			ConfigurationManager.Reset ();
-			ConfigurationManager.Load ();
+	[Fact]
+	public void Reset_Resets ()
+	{
+		Locations = ConfigLocations.DefaultOnly;
+		Reset ();
+		Assert.NotEmpty (Themes);
+		Assert.Equal ("Default", Themes.Theme);
+	}
 
 
-			// assert
-			Assert.NotEmpty (ConfigurationManager.Themes);
-			Assert.Equal ("Default", ConfigurationManager.Themes.Theme);
-			Assert.Equal (KeyCode.Q | KeyCode.CtrlMask, Application.QuitKey.KeyCode);
-			Assert.Equal (KeyCode.PageDown | KeyCode.CtrlMask, Application.AlternateForwardKey.KeyCode);
-			Assert.Equal (KeyCode.PageUp | KeyCode.CtrlMask, Application.AlternateBackwardKey.KeyCode);
-			Assert.False (Application.IsMouseDisabled);
+	[Fact]
+	public void Reset_and_ResetLoadWithLibraryResourcesOnly_are_same ()
+	{
+		Locations = ConfigLocations.DefaultOnly;
+		// arrange
+		Reset ();
+		Settings ["Application.QuitKey"].PropertyValue = new Key (KeyCode.Q);
+		Settings ["Application.AlternateForwardKey"].PropertyValue = new Key (KeyCode.F);
+		Settings ["Application.AlternateBackwardKey"].PropertyValue = new Key (KeyCode.B);
+		Settings ["Application.IsMouseDisabled"].PropertyValue = true;
+		Settings.Apply ();
+
+		// assert apply worked
+		Assert.Equal (KeyCode.Q, Application.QuitKey.KeyCode);
+		Assert.Equal (KeyCode.F, Application.AlternateForwardKey.KeyCode);
+		Assert.Equal (KeyCode.B, Application.AlternateBackwardKey.KeyCode);
+		Assert.True (Application.IsMouseDisabled);
+
+		//act
+		Reset ();
+
+		// assert
+		Assert.NotEmpty (Themes);
+		Assert.Equal ("Default", Themes.Theme);
+		Assert.Equal (KeyCode.Q | KeyCode.CtrlMask, Application.QuitKey.KeyCode);
+		Assert.Equal (KeyCode.PageDown | KeyCode.CtrlMask, Application.AlternateForwardKey.KeyCode);
+		Assert.Equal (KeyCode.PageUp | KeyCode.CtrlMask, Application.AlternateBackwardKey.KeyCode);
+		Assert.False (Application.IsMouseDisabled);
+
+		// arrange
+		Settings ["Application.QuitKey"].PropertyValue = new Key (KeyCode.Q);
+		Settings ["Application.AlternateForwardKey"].PropertyValue = new Key (KeyCode.F);
+		Settings ["Application.AlternateBackwardKey"].PropertyValue = new Key (KeyCode.B);
+		Settings ["Application.IsMouseDisabled"].PropertyValue = true;
+		Settings.Apply ();
+
+		Locations = ConfigLocations.DefaultOnly;
+
+		// act
+		Reset ();
+		Load ();
+
+		// assert
+		Assert.NotEmpty (Themes);
+		Assert.Equal ("Default", Themes.Theme);
+		Assert.Equal (KeyCode.Q | KeyCode.CtrlMask, Application.QuitKey.KeyCode);
+		Assert.Equal (KeyCode.PageDown | KeyCode.CtrlMask, Application.AlternateForwardKey.KeyCode);
+		Assert.Equal (KeyCode.PageUp | KeyCode.CtrlMask, Application.AlternateBackwardKey.KeyCode);
+		Assert.False (Application.IsMouseDisabled);
 
 
-		}
+	}
 
 
-		[Fact]
-		public void TestConfigProperties ()
-		{
-			ConfigurationManager.Locations = ConfigLocations.All;
-			ConfigurationManager.Reset ();
-
-			Assert.NotEmpty (ConfigurationManager.Settings);
-			// test that all ConfigProperites have our attribute
-			Assert.All (ConfigurationManager.Settings, item => Assert.NotEmpty (item.Value.PropertyInfo.CustomAttributes.Where (a => a.AttributeType == typeof (SerializableConfigurationProperty))));
-			Assert.Empty (ConfigurationManager.Settings.Where (cp => cp.Value.PropertyInfo.GetCustomAttribute (typeof (SerializableConfigurationProperty)) == null));
-
-			// Application is a static class
-			PropertyInfo pi = typeof (Application).GetProperty ("QuitKey");
-			Assert.Equal (pi, ConfigurationManager.Settings ["Application.QuitKey"].PropertyInfo);
-
-			// FrameView is not a static class and DefaultBorderStyle is Scope.Scheme
-			pi = typeof (FrameView).GetProperty ("DefaultBorderStyle");
-			Assert.False (ConfigurationManager.Settings.ContainsKey ("FrameView.DefaultBorderStyle"));
-			Assert.True (ConfigurationManager.Themes ["Default"].ContainsKey ("FrameView.DefaultBorderStyle"));
-		}
+	[Fact]
+	public void TestConfigProperties ()
+	{
+		Locations = ConfigLocations.All;
+		Reset ();
+
+		Assert.NotEmpty (Settings);
+		// test that all ConfigProperites have our attribute
+		Assert.All (Settings, item => Assert.NotEmpty (item.Value.PropertyInfo.CustomAttributes.Where (a => a.AttributeType == typeof (SerializableConfigurationProperty))));
+		Assert.Empty (Settings.Where (cp => cp.Value.PropertyInfo.GetCustomAttribute (typeof (SerializableConfigurationProperty)) == null));
+
+		// Application is a static class
+		var pi = typeof (Application).GetProperty ("QuitKey");
+		Assert.Equal (pi, Settings ["Application.QuitKey"].PropertyInfo);
+
+		// FrameView is not a static class and DefaultBorderStyle is Scope.Scheme
+		pi = typeof (FrameView).GetProperty ("DefaultBorderStyle");
+		Assert.False (Settings.ContainsKey ("FrameView.DefaultBorderStyle"));
+		Assert.True (Themes ["Default"].ContainsKey ("FrameView.DefaultBorderStyle"));
+	}
 
 
-		[Fact]
-		public void TestConfigPropertyOmitClassName ()
-		{
-			// Color.ColorShemes is serialzied as "ColorSchemes", not "Colors.ColorSchemes"
-			PropertyInfo pi = typeof (Colors).GetProperty ("ColorSchemes");
-			var scp = ((SerializableConfigurationProperty)pi.GetCustomAttribute (typeof (SerializableConfigurationProperty)));
-			Assert.True (scp.Scope == typeof (ThemeScope));
-			Assert.True (scp.OmitClassName);
-
-			ConfigurationManager.Reset ();
-			Assert.Equal (pi, ConfigurationManager.Themes ["Default"] ["ColorSchemes"].PropertyInfo);
-		}
+	[Fact]
+	public void TestConfigPropertyOmitClassName ()
+	{
+		// Color.ColorShemes is serialzied as "ColorSchemes", not "Colors.ColorSchemes"
+		var pi = typeof (Colors).GetProperty ("ColorSchemes");
+		var scp = (SerializableConfigurationProperty)pi.GetCustomAttribute (typeof (SerializableConfigurationProperty));
+		Assert.True (scp.Scope == typeof (ThemeScope));
+		Assert.True (scp.OmitClassName);
+
+		Reset ();
+		Assert.Equal (pi, Themes ["Default"] ["ColorSchemes"].PropertyInfo);
+	}
 
 
-		[Fact, AutoInitShutdown]
-		public void TestConfigurationManagerToJson ()
-		{
-			ConfigurationManager.Reset ();
-			ConfigurationManager.GetHardCodedDefaults ();
-			var stream = ConfigurationManager.ToStream ();
+	[Fact] [AutoInitShutdown]
+	public void TestConfigurationManagerToJson ()
+	{
+		Reset ();
+		GetHardCodedDefaults ();
+		var stream = ToStream ();
 
 
-			ConfigurationManager.Settings.Update (stream, "TestConfigurationManagerToJson");
-		}
+		Settings.Update (stream, "TestConfigurationManagerToJson");
+	}
 
 
-		[Fact, AutoInitShutdown (configLocation: ConfigLocations.None)]
-		public void TestConfigurationManagerInitDriver_NoLocations ()
-		{
+	[Fact] [AutoInitShutdown (configLocation: ConfigLocations.None)]
+	public void TestConfigurationManagerInitDriver_NoLocations ()
+	{
 
 
 
 
-		}
+	}
 
 
-		[Fact, AutoInitShutdown (configLocation: ConfigLocations.DefaultOnly)]
-		public void TestConfigurationManagerInitDriver ()
-		{
-			Assert.Equal ("Default", ConfigurationManager.Themes.Theme);
-			Assert.True (ConfigurationManager.Themes.ContainsKey ("Default"));
+	[Fact] [AutoInitShutdown (configLocation: ConfigLocations.DefaultOnly)]
+	public void TestConfigurationManagerInitDriver ()
+	{
+		Assert.Equal ("Default", Themes.Theme);
+		Assert.True (Themes.ContainsKey ("Default"));
 
 
-			Assert.Equal (KeyCode.Q | KeyCode.CtrlMask, Application.QuitKey.KeyCode);
+		Assert.Equal (KeyCode.Q | KeyCode.CtrlMask, Application.QuitKey.KeyCode);
 
 
-			Assert.Equal (new Color (Color.White), Colors.ColorSchemes ["Base"].Normal.Foreground);
-			Assert.Equal (new Color (Color.Blue), Colors.ColorSchemes ["Base"].Normal.Background);
+		Assert.Equal (new Color (Color.White), Colors.ColorSchemes ["Base"].Normal.Foreground);
+		Assert.Equal (new Color (Color.Blue), Colors.ColorSchemes ["Base"].Normal.Background);
 
 
-			// Change Base
-			var json = ConfigurationManager.ToStream ();
+		// Change Base
+		var json = ToStream ();
 
 
-			ConfigurationManager.Settings.Update (json, "TestConfigurationManagerInitDriver");
+		Settings.Update (json, "TestConfigurationManagerInitDriver");
 
 
-			var colorSchemes = ((Dictionary<string, ColorScheme>)ConfigurationManager.Themes [ConfigurationManager.Themes.Theme] ["ColorSchemes"].PropertyValue);
-			Assert.Equal (Colors.Base, colorSchemes ["Base"]);
-			Assert.Equal (Colors.TopLevel, colorSchemes ["TopLevel"]);
-			Assert.Equal (Colors.Error, colorSchemes ["Error"]);
-			Assert.Equal (Colors.Dialog, colorSchemes ["Dialog"]);
-			Assert.Equal (Colors.Menu, colorSchemes ["Menu"]);
+		var colorSchemes = (Dictionary<string, ColorScheme>)Themes [Themes.Theme] ["ColorSchemes"].PropertyValue;
+		Assert.Equal (Colors.Base, colorSchemes ["Base"]);
+		Assert.Equal (Colors.TopLevel, colorSchemes ["TopLevel"]);
+		Assert.Equal (Colors.Error, colorSchemes ["Error"]);
+		Assert.Equal (Colors.Dialog, colorSchemes ["Dialog"]);
+		Assert.Equal (Colors.Menu, colorSchemes ["Menu"]);
 
 
-			Colors.Base = colorSchemes ["Base"];
-			Colors.TopLevel = colorSchemes ["TopLevel"];
-			Colors.Error = colorSchemes ["Error"];
-			Colors.Dialog = colorSchemes ["Dialog"];
-			Colors.Menu = colorSchemes ["Menu"];
+		Colors.Base = colorSchemes ["Base"];
+		Colors.TopLevel = colorSchemes ["TopLevel"];
+		Colors.Error = colorSchemes ["Error"];
+		Colors.Dialog = colorSchemes ["Dialog"];
+		Colors.Menu = colorSchemes ["Menu"];
 
 
-			Assert.Equal (colorSchemes ["Base"], Colors.Base);
-			Assert.Equal (colorSchemes ["TopLevel"], Colors.TopLevel);
-			Assert.Equal (colorSchemes ["Error"], Colors.Error);
-			Assert.Equal (colorSchemes ["Dialog"], Colors.Dialog);
-			Assert.Equal (colorSchemes ["Menu"], Colors.Menu);
-		}
+		Assert.Equal (colorSchemes ["Base"], Colors.Base);
+		Assert.Equal (colorSchemes ["TopLevel"], Colors.TopLevel);
+		Assert.Equal (colorSchemes ["Error"], Colors.Error);
+		Assert.Equal (colorSchemes ["Dialog"], Colors.Dialog);
+		Assert.Equal (colorSchemes ["Menu"], Colors.Menu);
+	}
 
 
-		[Fact]
-		public void TestConfigurationManagerUpdateFromJson ()
-		{
-			// Arrange
-			string json = @"
+	[Fact]
+	public void TestConfigurationManagerUpdateFromJson ()
+	{
+		// Arrange
+		string json = @"
 {
 {
   ""$schema"": ""https://gui-cs.github.io/Terminal.Gui/schemas/tui-config-schema.json"",
   ""$schema"": ""https://gui-cs.github.io/Terminal.Gui/schemas/tui-config-schema.json"",
-  ""Application.QuitKey"": {
-    ""Key"": ""Alt-Z""
-  },
+  ""Application.QuitKey"": ""Alt-Z"",
   ""Theme"": ""Default"",
   ""Theme"": ""Default"",
   ""Themes"": [
   ""Themes"": [
     {
     {
@@ -493,39 +491,39 @@ namespace Terminal.Gui.ConfigurationTests {
 }					
 }					
 			";
 			";
 
 
-			ConfigurationManager.Reset ();
-			ConfigurationManager.ThrowOnJsonErrors = true;
+		Reset ();
+		ThrowOnJsonErrors = true;
 
 
-			ConfigurationManager.Settings.Update (json, "TestConfigurationManagerUpdateFromJson");
-			
-			Assert.Equal (KeyCode.Q | KeyCode.CtrlMask, Application.QuitKey.KeyCode);
-			Assert.Equal (KeyCode.Z | KeyCode.AltMask, ((Key)ConfigurationManager.Settings ["Application.QuitKey"].PropertyValue).KeyCode);
+		Settings.Update (json, "TestConfigurationManagerUpdateFromJson");
 
 
-			Assert.Equal ("Default", ConfigurationManager.Themes.Theme);
+		Assert.Equal (KeyCode.Q | KeyCode.CtrlMask, Application.QuitKey.KeyCode);
+		Assert.Equal (KeyCode.Z | KeyCode.AltMask, ((Key)Settings ["Application.QuitKey"].PropertyValue).KeyCode);
 
 
-			Assert.Equal (new Color (Color.White), Colors.ColorSchemes ["Base"].Normal.Foreground);
-			Assert.Equal (new Color (Color.Blue), Colors.ColorSchemes ["Base"].Normal.Background);
+		Assert.Equal ("Default", Themes.Theme);
 
 
-			var colorSchemes = (Dictionary<string, ColorScheme>)Themes.First ().Value ["ColorSchemes"].PropertyValue;
-			Assert.Equal (new Color (Color.White), colorSchemes ["Base"].Normal.Foreground);
-			Assert.Equal (new Color (Color.Blue), colorSchemes ["Base"].Normal.Background);
+		Assert.Equal (new Color (Color.White), Colors.ColorSchemes ["Base"].Normal.Foreground);
+		Assert.Equal (new Color (Color.Blue), Colors.ColorSchemes ["Base"].Normal.Background);
 
 
-			// Now re-apply
-			ConfigurationManager.Apply ();
+		var colorSchemes = (Dictionary<string, ColorScheme>)Themes.First ().Value ["ColorSchemes"].PropertyValue;
+		Assert.Equal (new Color (Color.White), colorSchemes ["Base"].Normal.Foreground);
+		Assert.Equal (new Color (Color.Blue), colorSchemes ["Base"].Normal.Background);
 
 
-			Assert.Equal (KeyCode.Z | KeyCode.AltMask, Application.QuitKey.KeyCode);
-			Assert.Equal ("Default", ConfigurationManager.Themes.Theme);
+		// Now re-apply
+		Apply ();
 
 
-			Assert.Equal (new Color (Color.White), Colors.ColorSchemes ["Base"].Normal.Foreground);
-			Assert.Equal (new Color (Color.Blue), Colors.ColorSchemes ["Base"].Normal.Background);
-		}
+		Assert.Equal (KeyCode.Z | KeyCode.AltMask, Application.QuitKey.KeyCode);
+		Assert.Equal ("Default", Themes.Theme);
 
 
-		[Fact, AutoInitShutdown]
-		public void TestConfigurationManagerInvalidJsonThrows ()
-		{
-			ConfigurationManager.ThrowOnJsonErrors = true;
-			// "yellow" is not a color
-			string json = @"
+		Assert.Equal (new Color (Color.White), Colors.ColorSchemes ["Base"].Normal.Foreground);
+		Assert.Equal (new Color (Color.Blue), Colors.ColorSchemes ["Base"].Normal.Background);
+	}
+
+	[Fact] [AutoInitShutdown]
+	public void TestConfigurationManagerInvalidJsonThrows ()
+	{
+		ThrowOnJsonErrors = true;
+		// "yellow" is not a color
+		string json = @"
 			{
 			{
 				""Themes"" : [
 				""Themes"" : [
                                         {
                                         {
@@ -545,11 +543,11 @@ namespace Terminal.Gui.ConfigurationTests {
 				]
 				]
 			}";
 			}";
 
 
-			JsonException jsonException = Assert.Throws<JsonException> (() => ConfigurationManager.Settings.Update (json, "test"));
-			Assert.Equal ("Unexpected color name: brown.", jsonException.Message);
+		var jsonException = Assert.Throws<JsonException> (() => Settings.Update (json, "test"));
+		Assert.Equal ("Unexpected color name: brown.", jsonException.Message);
 
 
-			// AbNormal is not a ColorScheme attribute
-			json = @"
+		// AbNormal is not a ColorScheme attribute
+		json = @"
 			{
 			{
 				""Themes"" : [ 
 				""Themes"" : [ 
                                         {
                                         {
@@ -569,11 +567,11 @@ namespace Terminal.Gui.ConfigurationTests {
 				]
 				]
 			}";
 			}";
 
 
-			jsonException = Assert.Throws<JsonException> (() => ConfigurationManager.Settings.Update (json, "test"));
-			Assert.Equal ("Unrecognized ColorScheme Attribute name: AbNormal.", jsonException.Message);
+		jsonException = Assert.Throws<JsonException> (() => Settings.Update (json, "test"));
+		Assert.Equal ("Unrecognized ColorScheme Attribute name: AbNormal.", jsonException.Message);
 
 
-			// Modify hotNormal background only 
-			json = @"
+		// Modify hotNormal background only 
+		json = @"
 			{
 			{
 				""Themes"" : [ 
 				""Themes"" : [ 
                                         {
                                         {
@@ -592,31 +590,31 @@ namespace Terminal.Gui.ConfigurationTests {
 				]
 				]
 			}";
 			}";
 
 
-			jsonException = Assert.Throws<JsonException> (() => ConfigurationManager.Settings.Update (json, "test"));
-			Assert.Equal ("Both Foreground and Background colors must be provided.", jsonException.Message);
+		jsonException = Assert.Throws<JsonException> (() => Settings.Update (json, "test"));
+		Assert.Equal ("Both Foreground and Background colors must be provided.", jsonException.Message);
 
 
-			// Unknown proeprty
-			json = @"
+		// Unknown proeprty
+		json = @"
 			{
 			{
 				""Unknown"" : ""Not known""
 				""Unknown"" : ""Not known""
 			}";
 			}";
 
 
-			jsonException = Assert.Throws<JsonException> (() => ConfigurationManager.Settings.Update (json, "test"));
-			Assert.StartsWith ("Unknown property", jsonException.Message);
+		jsonException = Assert.Throws<JsonException> (() => Settings.Update (json, "test"));
+		Assert.StartsWith ("Unknown property", jsonException.Message);
 
 
-			Assert.Equal (0, ConfigurationManager.jsonErrors.Length);
+		Assert.Equal (0, jsonErrors.Length);
 
 
-			ConfigurationManager.ThrowOnJsonErrors = false;
-		}
+		ThrowOnJsonErrors = false;
+	}
 
 
-		[Fact]
-		public void TestConfigurationManagerInvalidJsonLogs ()
-		{
-			Application.Init (new FakeDriver ());
+	[Fact]
+	public void TestConfigurationManagerInvalidJsonLogs ()
+	{
+		Application.Init (new FakeDriver ());
 
 
-			ConfigurationManager.ThrowOnJsonErrors = false;
-			// "brown" is not a color
-			string json = @"
+		ThrowOnJsonErrors = false;
+		// "brown" is not a color
+		string json = @"
 			{
 			{
 				""Themes"" : [ 
 				""Themes"" : [ 
                                         {
                                         {
@@ -636,10 +634,10 @@ namespace Terminal.Gui.ConfigurationTests {
 				}
 				}
 			}";
 			}";
 
 
-			ConfigurationManager.Settings.Update (json, "test");
+		Settings.Update (json, "test");
 
 
-			// AbNormal is not a ColorScheme attribute
-			json = @"
+		// AbNormal is not a ColorScheme attribute
+		json = @"
 			{
 			{
 				""Themes"" : [ 
 				""Themes"" : [ 
                                         {
                                         {
@@ -659,10 +657,10 @@ namespace Terminal.Gui.ConfigurationTests {
 				}
 				}
 			}";
 			}";
 
 
-			ConfigurationManager.Settings.Update (json, "test");
+		Settings.Update (json, "test");
 
 
-			// Modify hotNormal background only 
-			json = @"
+		// Modify hotNormal background only 
+		json = @"
 			{
 			{
 				""Themes"" :  [ 
 				""Themes"" :  [ 
                                         {
                                         {
@@ -681,111 +679,109 @@ namespace Terminal.Gui.ConfigurationTests {
 				}
 				}
 			}";
 			}";
 
 
-			ConfigurationManager.Settings.Update (json, "test");
+		Settings.Update (json, "test");
 
 
-			ConfigurationManager.Settings.Update ("{}}", "test");
+		Settings.Update ("{}}", "test");
 
 
-			Assert.NotEqual (0, ConfigurationManager.jsonErrors.Length);
+		Assert.NotEqual (0, jsonErrors.Length);
 
 
-			Application.Shutdown ();
+		Application.Shutdown ();
 
 
-			ConfigurationManager.ThrowOnJsonErrors = false;
-		}
+		ThrowOnJsonErrors = false;
+	}
 
 
-		[Fact, AutoInitShutdown]
-		public void LoadConfigurationFromAllSources_ShouldLoadSettingsFromAllSources ()
-		{
-			//var _configFilename = "config.json";
-			//// Arrange
-			//// Create a mock of the configuration files in all sources
-			//// Home directory
-			//string homeDir = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.UserProfile), ".tui");
-			//if (!Directory.Exists (homeDir)) {
-			//	Directory.CreateDirectory (homeDir);
-			//}
-			//string globalConfigFile = Path.Combine (homeDir, _configFilename);
-			//string appSpecificConfigFile = Path.Combine (homeDir, "appname.config.json");
-			//File.WriteAllText (globalConfigFile, "{\"Settings\": {\"TestSetting\":\"Global\"}}");
-			//File.WriteAllText (appSpecificConfigFile, "{\"Settings\": {\"TestSetting\":\"AppSpecific\"}}");
-
-			//// App directory
-			//string appDir = Directory.GetCurrentDirectory ();
-			//string appDirGlobalConfigFile = Path.Combine (appDir, _configFilename);
-			//string appDirAppSpecificConfigFile = Path.Combine (appDir, "appname.config.json");
-			//File.WriteAllText (appDirGlobalConfigFile, "{\"Settings\": {\"TestSetting\":\"GlobalAppDir\"}}");
-			//File.WriteAllText (appDirAppSpecificConfigFile, "{\"Settings\": {\"TestSetting\":\"AppSpecificAppDir\"}}");
-
-			//// App resources
-			//// ...
-
-			//// Act
-			//ConfigurationManager.Locations = ConfigurationManager.ConfigLocation.All;
-			//ConfigurationManager.Load ();
-
-			//// Assert
-			//// Check that the settings from the highest precedence source are loaded
-			//Assert.Equal ("AppSpecific", ConfigurationManager.Config.Settings.TestSetting);
-		}
+	[Fact] [AutoInitShutdown]
+	public void LoadConfigurationFromAllSources_ShouldLoadSettingsFromAllSources ()
+	{
+		//var _configFilename = "config.json";
+		//// Arrange
+		//// Create a mock of the configuration files in all sources
+		//// Home directory
+		//string homeDir = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.UserProfile), ".tui");
+		//if (!Directory.Exists (homeDir)) {
+		//	Directory.CreateDirectory (homeDir);
+		//}
+		//string globalConfigFile = Path.Combine (homeDir, _configFilename);
+		//string appSpecificConfigFile = Path.Combine (homeDir, "appname.config.json");
+		//File.WriteAllText (globalConfigFile, "{\"Settings\": {\"TestSetting\":\"Global\"}}");
+		//File.WriteAllText (appSpecificConfigFile, "{\"Settings\": {\"TestSetting\":\"AppSpecific\"}}");
+
+		//// App directory
+		//string appDir = Directory.GetCurrentDirectory ();
+		//string appDirGlobalConfigFile = Path.Combine (appDir, _configFilename);
+		//string appDirAppSpecificConfigFile = Path.Combine (appDir, "appname.config.json");
+		//File.WriteAllText (appDirGlobalConfigFile, "{\"Settings\": {\"TestSetting\":\"GlobalAppDir\"}}");
+		//File.WriteAllText (appDirAppSpecificConfigFile, "{\"Settings\": {\"TestSetting\":\"AppSpecificAppDir\"}}");
+
+		//// App resources
+		//// ...
+
+		//// Act
+		//ConfigurationManager.Locations = ConfigurationManager.ConfigLocation.All;
+		//ConfigurationManager.Load ();
+
+		//// Assert
+		//// Check that the settings from the highest precedence source are loaded
+		//Assert.Equal ("AppSpecific", ConfigurationManager.Config.Settings.TestSetting);
+	}
 
 
-		[Fact]
-		public void Load_FiresUpdated ()
+	[Fact]
+	public void Load_FiresUpdated ()
+	{
+		Reset ();
+
+		Settings ["Application.QuitKey"].PropertyValue = new Key (KeyCode.Q);
+		Settings ["Application.AlternateForwardKey"].PropertyValue = new Key (KeyCode.F);
+		Settings ["Application.AlternateBackwardKey"].PropertyValue = new Key (KeyCode.B);
+		Settings ["Application.IsMouseDisabled"].PropertyValue = true;
+
+		Updated += ConfigurationManager_Updated;
+		bool fired = false;
+		void ConfigurationManager_Updated (object sender, ConfigurationManagerEventArgs obj)
 		{
 		{
-			ConfigurationManager.Reset ();
+			fired = true;
+			// assert
+			Assert.Equal (KeyCode.Q | KeyCode.CtrlMask, ((Key)Settings ["Application.QuitKey"].PropertyValue).KeyCode);
+			Assert.Equal (KeyCode.PageDown | KeyCode.CtrlMask, ((Key)Settings ["Application.AlternateForwardKey"].PropertyValue).KeyCode);
+			Assert.Equal (KeyCode.PageUp | KeyCode.CtrlMask, ((Key)Settings ["Application.AlternateBackwardKey"].PropertyValue).KeyCode);
+			Assert.False ((bool)Settings ["Application.IsMouseDisabled"].PropertyValue);
+		}
 
 
-			ConfigurationManager.Settings ["Application.QuitKey"].PropertyValue = new Key (KeyCode.Q);
-			ConfigurationManager.Settings ["Application.AlternateForwardKey"].PropertyValue = new Key (KeyCode.F);
-			ConfigurationManager.Settings ["Application.AlternateBackwardKey"].PropertyValue = new Key (KeyCode.B);
-			ConfigurationManager.Settings ["Application.IsMouseDisabled"].PropertyValue = true;
+		Load (true);
 
 
-			ConfigurationManager.Updated += ConfigurationManager_Updated;
-			bool fired = false;
-			void ConfigurationManager_Updated (object sender, ConfigurationManagerEventArgs obj)
-			{
-				fired = true;
-				// assert
-				Assert.Equal (KeyCode.Q | KeyCode.CtrlMask, ((Key)ConfigurationManager.Settings ["Application.QuitKey"].PropertyValue).KeyCode);
-				Assert.Equal (KeyCode.PageDown | KeyCode.CtrlMask, ((Key)ConfigurationManager.Settings ["Application.AlternateForwardKey"].PropertyValue).KeyCode);
-				Assert.Equal (KeyCode.PageUp | KeyCode.CtrlMask, ((Key)ConfigurationManager.Settings ["Application.AlternateBackwardKey"].PropertyValue).KeyCode);
-				Assert.False ((bool)ConfigurationManager.Settings ["Application.IsMouseDisabled"].PropertyValue);
-			}
+		// assert
+		Assert.True (fired);
 
 
-			ConfigurationManager.Load (true);
+		Updated -= ConfigurationManager_Updated;
+	}
 
 
+	[Fact]
+	public void Apply_FiresApplied ()
+	{
+		Reset ();
+		Applied += ConfigurationManager_Applied;
+		bool fired = false;
+		void ConfigurationManager_Applied (object sender, ConfigurationManagerEventArgs obj)
+		{
+			fired = true;
 			// assert
 			// assert
-			Assert.True (fired);
-
-			ConfigurationManager.Updated -= ConfigurationManager_Updated;
+			Assert.Equal (KeyCode.Q, Application.QuitKey.KeyCode);
+			Assert.Equal (KeyCode.F, Application.AlternateForwardKey.KeyCode);
+			Assert.Equal (KeyCode.B, Application.AlternateBackwardKey.KeyCode);
+			Assert.True (Application.IsMouseDisabled);
 		}
 		}
 
 
-		[Fact]
-		public void Apply_FiresApplied ()
-		{
-			ConfigurationManager.Reset ();
-			ConfigurationManager.Applied += ConfigurationManager_Applied;
-			bool fired = false;
-			void ConfigurationManager_Applied (object sender, ConfigurationManagerEventArgs obj)
-			{
-				fired = true;
-				// assert
-				Assert.Equal (KeyCode.Q, Application.QuitKey.KeyCode);
-				Assert.Equal (KeyCode.F, Application.AlternateForwardKey.KeyCode);
-				Assert.Equal (KeyCode.B, Application.AlternateBackwardKey.KeyCode);
-				Assert.True (Application.IsMouseDisabled);
-			}
-
-			// act
-			ConfigurationManager.Settings ["Application.QuitKey"].PropertyValue = new Key (KeyCode.Q);
-			ConfigurationManager.Settings ["Application.AlternateForwardKey"].PropertyValue = new Key (KeyCode.F);
-			ConfigurationManager.Settings ["Application.AlternateBackwardKey"].PropertyValue = new Key (KeyCode.B);
-			ConfigurationManager.Settings ["Application.IsMouseDisabled"].PropertyValue = true;
-
-			ConfigurationManager.Apply ();
+		// act
+		Settings ["Application.QuitKey"].PropertyValue = new Key (KeyCode.Q);
+		Settings ["Application.AlternateForwardKey"].PropertyValue = new Key (KeyCode.F);
+		Settings ["Application.AlternateBackwardKey"].PropertyValue = new Key (KeyCode.B);
+		Settings ["Application.IsMouseDisabled"].PropertyValue = true;
 
 
-			// assert
-			Assert.True (fired);
+		Apply ();
 
 
-			ConfigurationManager.Applied -= ConfigurationManager_Applied;
-		}
-	}
-}
+		// assert
+		Assert.True (fired);
 
 
+		Applied -= ConfigurationManager_Applied;
+	}
+}

+ 10 - 10
UnitTests/Configuration/JsonConverterTests.cs

@@ -278,16 +278,16 @@ public class KeyCodeJsonConverterTests {
 
 
 public class KeyJsonConverterTests {
 public class KeyJsonConverterTests {
 	[Theory]
 	[Theory]
-	[InlineData (KeyCode.A, "{\"Key\":\"a\"}")]
-	[InlineData ((KeyCode)'â', "{\"Key\":\"â\"}")]
-	[InlineData (KeyCode.A | KeyCode.ShiftMask, "{\"Key\":\"A\"}")]
-	[InlineData (KeyCode.A | KeyCode.CtrlMask, "{\"Key\":\"Ctrl+A\"}")]
-	[InlineData (KeyCode.A | KeyCode.AltMask | KeyCode.CtrlMask, "{\"Key\":\"Ctrl+Alt+A\"}")]
-	[InlineData ((KeyCode)'a' | KeyCode.AltMask | KeyCode.CtrlMask, "{\"Key\":\"Ctrl+Alt+A\"}")]
-	[InlineData ((KeyCode)'a' | KeyCode.ShiftMask, "{\"Key\":\"A\"}")]
-	[InlineData (KeyCode.Delete | KeyCode.AltMask | KeyCode.CtrlMask, "{\"Key\":\"Ctrl+Alt+Delete\"}")]
-	[InlineData (KeyCode.D4, "{\"Key\":\"4\"}")]
-	[InlineData (KeyCode.Esc, "{\"Key\":\"Esc\"}")]
+	[InlineData (KeyCode.A, "\"a\"")]
+	[InlineData ((KeyCode)'â', "\"â\"")]
+	[InlineData (KeyCode.A | KeyCode.ShiftMask, "\"A\"")]
+	[InlineData (KeyCode.A | KeyCode.CtrlMask, "\"Ctrl+A\"")]
+	[InlineData (KeyCode.A | KeyCode.AltMask | KeyCode.CtrlMask, "\"Ctrl+Alt+A\"")]
+	[InlineData ((KeyCode)'a' | KeyCode.AltMask | KeyCode.CtrlMask, "\"Ctrl+Alt+A\"")]
+	[InlineData ((KeyCode)'a' | KeyCode.ShiftMask, "\"A\"")]
+	[InlineData (KeyCode.Delete | KeyCode.AltMask | KeyCode.CtrlMask, "\"Ctrl+Alt+Delete\"")]
+	[InlineData (KeyCode.D4, "\"4\"")]
+	[InlineData (KeyCode.Esc, "\"Esc\"")]
 	public void TestKey_Serialize (KeyCode key, string expected)
 	public void TestKey_Serialize (KeyCode key, string expected)
 	{
 	{
 		// Arrange
 		// Arrange

+ 69 - 69
UnitTests/Configuration/SettingsScopeTests.cs

@@ -7,74 +7,74 @@ using System.Text;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using static Terminal.Gui.ConfigurationManager;
 using static Terminal.Gui.ConfigurationManager;
 
 
-namespace Terminal.Gui.ConfigurationTests {
-	public class SettingsScopeTests {
-
-		[Fact]
-		public void GetHardCodedDefaults_ShouldSetProperties ()
-		{
-			ConfigurationManager.Reset ();
-
-			Assert.Equal (3, ((Dictionary<string, ThemeScope>)ConfigurationManager.Settings ["Themes"].PropertyValue).Count);
-
-			ConfigurationManager.GetHardCodedDefaults ();
-			Assert.NotEmpty (ConfigurationManager.Themes);
-			Assert.Equal ("Default", ConfigurationManager.Themes.Theme);
-
-			Assert.True (ConfigurationManager.Settings ["Application.QuitKey"].PropertyValue is Key);
-			Assert.True (ConfigurationManager.Settings ["Application.AlternateForwardKey"].PropertyValue is Key);
-			Assert.True (ConfigurationManager.Settings ["Application.AlternateBackwardKey"].PropertyValue is Key);
-			Assert.True (ConfigurationManager.Settings ["Application.IsMouseDisabled"].PropertyValue is bool);
-
-			Assert.True (ConfigurationManager.Settings ["Theme"].PropertyValue is string);
-			Assert.Equal ("Default", ConfigurationManager.Settings ["Theme"].PropertyValue as string);
-
-			Assert.True (ConfigurationManager.Settings ["Themes"].PropertyValue is Dictionary<string, ThemeScope>);
-			Assert.Single (((Dictionary<string, ThemeScope>)ConfigurationManager.Settings ["Themes"].PropertyValue));
-
-		}
-
-		[Fact, AutoInitShutdown]
-		public void Apply_ShouldApplyProperties ()
-		{
-			// arrange
-			Assert.Equal (KeyCode.Q | KeyCode.CtrlMask, ((Key)ConfigurationManager.Settings ["Application.QuitKey"].PropertyValue).KeyCode);
-			Assert.Equal (KeyCode.PageDown | KeyCode.CtrlMask, ((Key)ConfigurationManager.Settings ["Application.AlternateForwardKey"].PropertyValue).KeyCode);
-			Assert.Equal (KeyCode.PageUp | KeyCode.CtrlMask, ((Key)ConfigurationManager.Settings ["Application.AlternateBackwardKey"].PropertyValue).KeyCode);
-			Assert.False ((bool)ConfigurationManager.Settings ["Application.IsMouseDisabled"].PropertyValue);
-
-			// act
-			ConfigurationManager.Settings ["Application.QuitKey"].PropertyValue = new Key (KeyCode.Q);
-			ConfigurationManager.Settings ["Application.AlternateForwardKey"].PropertyValue = new Key (KeyCode.F);
-			ConfigurationManager.Settings ["Application.AlternateBackwardKey"].PropertyValue = new Key (KeyCode.B);
-			ConfigurationManager.Settings ["Application.IsMouseDisabled"].PropertyValue = true;
-
-			ConfigurationManager.Settings.Apply ();
-
-			// assert
-			Assert.Equal (KeyCode.Q, Application.QuitKey.KeyCode);
-			Assert.Equal (KeyCode.F, Application.AlternateForwardKey.KeyCode);
-			Assert.Equal (KeyCode.B, Application.AlternateBackwardKey.KeyCode);
-			Assert.True (Application.IsMouseDisabled);
-		}
-
-		[Fact, AutoInitShutdown]
-		public void CopyUpdatedProperitesFrom_ShouldCopyChangedPropertiesOnly ()
-		{
-			ConfigurationManager.Settings ["Application.QuitKey"].PropertyValue = new Key (KeyCode.End); ;
-
-			var updatedSettings = new SettingsScope ();
-
-			///Don't set Quitkey
-			updatedSettings ["Application.AlternateForwardKey"].PropertyValue = new Key (KeyCode.F);
-			updatedSettings ["Application.AlternateBackwardKey"].PropertyValue = new Key (KeyCode.B);
-			updatedSettings ["Application.IsMouseDisabled"].PropertyValue = true;
-
-			ConfigurationManager.Settings.Update (updatedSettings);
-			Assert.Equal (KeyCode.End, ((Key)ConfigurationManager.Settings ["Application.QuitKey"].PropertyValue).KeyCode);
-			Assert.Equal (KeyCode.F,  ((Key)updatedSettings ["Application.AlternateForwardKey"].PropertyValue).KeyCode);
-			Assert.Equal (KeyCode.B, ((Key)updatedSettings ["Application.AlternateBackwardKey"].PropertyValue).KeyCode);
-			Assert.True ((bool)updatedSettings ["Application.IsMouseDisabled"].PropertyValue);
-		}
+namespace Terminal.Gui.ConfigurationTests; 
+
+public class SettingsScopeTests {
+	[Fact]
+	public void GetHardCodedDefaults_ShouldSetProperties ()
+	{
+		Reset ();
+
+		Assert.Equal (3, ((Dictionary<string, ThemeScope>)Settings ["Themes"].PropertyValue).Count);
+
+		GetHardCodedDefaults ();
+		Assert.NotEmpty (Themes);
+		Assert.Equal ("Default", Themes.Theme);
+
+		Assert.True (Settings ["Application.QuitKey"].PropertyValue is Key);
+		Assert.True (Settings ["Application.AlternateForwardKey"].PropertyValue is Key);
+		Assert.True (Settings ["Application.AlternateBackwardKey"].PropertyValue is Key);
+		Assert.True (Settings ["Application.IsMouseDisabled"].PropertyValue is bool);
+
+		Assert.True (Settings ["Theme"].PropertyValue is string);
+		Assert.Equal ("Default", Settings ["Theme"].PropertyValue as string);
+
+		Assert.True (Settings ["Themes"].PropertyValue is Dictionary<string, ThemeScope>);
+		Assert.Single ((Dictionary<string, ThemeScope>)Settings ["Themes"].PropertyValue);
+
+	}
+
+	[Fact] [AutoInitShutdown]
+	public void Apply_ShouldApplyProperties ()
+	{
+		// arrange
+		Assert.Equal (KeyCode.Q | KeyCode.CtrlMask, ((Key)Settings ["Application.QuitKey"].PropertyValue).KeyCode);
+		Assert.Equal (KeyCode.PageDown | KeyCode.CtrlMask, ((Key)Settings ["Application.AlternateForwardKey"].PropertyValue).KeyCode);
+		Assert.Equal (KeyCode.PageUp | KeyCode.CtrlMask, ((Key)Settings ["Application.AlternateBackwardKey"].PropertyValue).KeyCode);
+		Assert.False ((bool)Settings ["Application.IsMouseDisabled"].PropertyValue);
+
+		// act
+		Settings ["Application.QuitKey"].PropertyValue = new Key (KeyCode.Q);
+		Settings ["Application.AlternateForwardKey"].PropertyValue = new Key (KeyCode.F);
+		Settings ["Application.AlternateBackwardKey"].PropertyValue = new Key (KeyCode.B);
+		Settings ["Application.IsMouseDisabled"].PropertyValue = true;
+
+		Settings.Apply ();
+
+		// assert
+		Assert.Equal (KeyCode.Q, Application.QuitKey.KeyCode);
+		Assert.Equal (KeyCode.F, Application.AlternateForwardKey.KeyCode);
+		Assert.Equal (KeyCode.B, Application.AlternateBackwardKey.KeyCode);
+		Assert.True (Application.IsMouseDisabled);
+	}
+
+	[Fact] [AutoInitShutdown]
+	public void CopyUpdatedPropertiesFrom_ShouldCopyChangedPropertiesOnly ()
+	{
+		Settings ["Application.QuitKey"].PropertyValue = new Key (KeyCode.End);
+		;
+
+		var updatedSettings = new SettingsScope ();
+
+		///Don't set Quitkey
+		updatedSettings ["Application.AlternateForwardKey"].PropertyValue = new Key (KeyCode.F);
+		updatedSettings ["Application.AlternateBackwardKey"].PropertyValue = new Key (KeyCode.B);
+		updatedSettings ["Application.IsMouseDisabled"].PropertyValue = true;
+
+		Settings.Update (updatedSettings);
+		Assert.Equal (KeyCode.End, ((Key)Settings ["Application.QuitKey"].PropertyValue).KeyCode);
+		Assert.Equal (KeyCode.F, ((Key)updatedSettings ["Application.AlternateForwardKey"].PropertyValue).KeyCode);
+		Assert.Equal (KeyCode.B, ((Key)updatedSettings ["Application.AlternateBackwardKey"].PropertyValue).KeyCode);
+		Assert.True ((bool)updatedSettings ["Application.IsMouseDisabled"].PropertyValue);
 	}
 	}
 }
 }

+ 143 - 9
UnitTests/Input/KeyTests.cs

@@ -27,6 +27,126 @@ public class KeyTests {
 		Assert.Equal (key, eventArgs.KeyCode);
 		Assert.Equal (key, eventArgs.KeyCode);
 	}
 	}
 
 
+	[Theory]
+	[InlineData ('a', KeyCode.A)]
+	[InlineData ('A', KeyCode.A | KeyCode.ShiftMask)]
+	[InlineData ('z', KeyCode.Z)]
+	[InlineData ('Z', KeyCode.Z | KeyCode.ShiftMask)]
+	[InlineData (' ', KeyCode.Space)]
+	[InlineData ('1', KeyCode.D1)]
+	[InlineData ('!', (KeyCode)'!')]
+	[InlineData ('\n', KeyCode.Enter)]
+	[InlineData ('\t', KeyCode.Tab)]
+	[InlineData ('\r', (KeyCode)13)]
+	[InlineData ('ó', (KeyCode)'ó')]
+	[InlineData ('Ó', (KeyCode)'Ó')]
+	[InlineData ('❿', (KeyCode)'❿')]
+	[InlineData ('☑', (KeyCode)'☑')]
+	[InlineData ('英', (KeyCode)'英')]
+	[InlineData ('{', (KeyCode)'{')]
+	[InlineData ('\'', (KeyCode)'\'')]
+	[InlineData ('\xFFFF', (KeyCode)0xFFFF)]
+	[InlineData ('\x0', (KeyCode)0x0)]
+	public void Constructor_Char (char ch, KeyCode expectedKeyCode)
+	{
+		var key = new Key (ch);
+		Assert.Equal (expectedKeyCode, key.KeyCode);
+	}
+
+
+	// TryParse
+	[Theory]
+	[InlineData ("a", KeyCode.A)]
+	[InlineData ("Ctrl+A", KeyCode.A | KeyCode.CtrlMask)]
+	[InlineData ("Alt+A", KeyCode.A | KeyCode.AltMask)]
+	[InlineData ("Shift+A", KeyCode.A | KeyCode.ShiftMask)]
+	[InlineData ("A", KeyCode.A | KeyCode.ShiftMask)]
+	[InlineData ("â", (KeyCode)'â')]
+	[InlineData ("Shift+â", (KeyCode)'â' | KeyCode.ShiftMask)]
+	[InlineData ("Shift+Â", (KeyCode)'Â' | KeyCode.ShiftMask)]
+	[InlineData ("Ctrl+Shift+CursorUp", KeyCode.ShiftMask | KeyCode.CtrlMask | KeyCode.CursorUp)]
+	[InlineData ("Ctrl+Alt+Shift+CursorUp", KeyCode.ShiftMask | KeyCode.CtrlMask | KeyCode.AltMask | KeyCode.CursorUp)]
+	[InlineData ("ctrl+alt+shift+cursorup", KeyCode.ShiftMask | KeyCode.CtrlMask | KeyCode.AltMask | KeyCode.CursorUp)]
+	[InlineData ("CTRL+ALT+SHIFT+CURSORUP", KeyCode.ShiftMask | KeyCode.CtrlMask | KeyCode.AltMask | KeyCode.CursorUp)]
+	[InlineData ("Ctrl+Alt+Shift+Delete", KeyCode.ShiftMask | KeyCode.CtrlMask | KeyCode.AltMask | KeyCode.Delete)]
+	[InlineData ("Ctrl+Alt+Shift+Enter", KeyCode.ShiftMask | KeyCode.CtrlMask | KeyCode.AltMask | KeyCode.Enter)]
+	[InlineData ("Tab", KeyCode.Tab)]
+	[InlineData ("Shift+Tab", KeyCode.Tab | KeyCode.ShiftMask)]
+	[InlineData ("Ctrl+Tab", KeyCode.Tab | KeyCode.CtrlMask)]
+	[InlineData ("Alt+Tab", KeyCode.Tab | KeyCode.AltMask)]
+	[InlineData ("Ctrl+Shift+Tab", KeyCode.Tab | KeyCode.ShiftMask | KeyCode.CtrlMask)]
+	[InlineData ("Ctrl+Alt+Tab", KeyCode.Tab | KeyCode.AltMask | KeyCode.CtrlMask)]
+	[InlineData ("", KeyCode.Null)]
+	[InlineData (" ", KeyCode.Space)]
+	[InlineData ("Shift+ ", KeyCode.Space | KeyCode.ShiftMask)]
+	[InlineData ("Ctrl+ ", KeyCode.Space | KeyCode.CtrlMask)]
+	[InlineData ("Alt+ ", KeyCode.Space | KeyCode.AltMask)]
+	[InlineData ("F1", KeyCode.F1)]
+	[InlineData ("0", KeyCode.D0)]
+	[InlineData ("9", KeyCode.D9)]
+	[InlineData ("D0", KeyCode.D0)]
+	[InlineData ("65", KeyCode.A | KeyCode.ShiftMask)]
+	[InlineData ("97", KeyCode.A)]
+	[InlineData ("Shift", KeyCode.ShiftKey)]
+	[InlineData ("Ctrl", KeyCode.CtrlKey)]
+	[InlineData ("Ctrl-A", KeyCode.A | KeyCode.CtrlMask)]
+	[InlineData ("Alt-A", KeyCode.A | KeyCode.AltMask)]
+	[InlineData ("A-Ctrl", KeyCode.A | KeyCode.CtrlMask)]
+	[InlineData ("Alt-A-Ctrl", KeyCode.A | KeyCode.CtrlMask | KeyCode.AltMask)]
+	public void Constructor_String_Valid (string keyString, Key expected)
+	{
+		Key key = new Key (keyString);
+		Assert.Equal (((Key)expected).ToString (), key.ToString ());
+	}
+
+	[Theory]
+	[InlineData("Barf")]
+	public void Constructor_String_Invalid_Throws (string keyString)
+	{
+		Assert.Throws<ArgumentException> (() => new Key (keyString));
+	}
+
+	[Theory]
+	[InlineData ('a', KeyCode.A)]
+	[InlineData ('A', KeyCode.A | KeyCode.ShiftMask)]
+	[InlineData ('z', KeyCode.Z)]
+	[InlineData ('Z', KeyCode.Z | KeyCode.ShiftMask)]
+	[InlineData (' ', KeyCode.Space)]
+	[InlineData ('1', KeyCode.D1)]
+	[InlineData ('!', (KeyCode)'!')]
+	[InlineData ('\n', KeyCode.Enter)]
+	[InlineData ('\t', KeyCode.Tab)]
+	[InlineData ('\r', (KeyCode)13)]
+	[InlineData ('ó', (KeyCode)'ó')]
+	[InlineData ('Ó', (KeyCode)'Ó')]
+	[InlineData ('❿', (KeyCode)'❿')]
+	[InlineData ('☑', (KeyCode)'☑')]
+	[InlineData ('英', (KeyCode)'英')]
+	[InlineData ('{', (KeyCode)'{')]
+	[InlineData ('\'', (KeyCode)'\'')]
+	[InlineData ('\xFFFF', (KeyCode)0xFFFF)]
+	[InlineData ('\x0', (KeyCode)0x0)]
+	public void Cast_Char_To_Key (char ch, KeyCode expectedKeyCode)
+	{
+		var key = (Key)ch;
+		Assert.Equal (expectedKeyCode, key.KeyCode);
+	}
+
+	// string cast operators
+	[Fact]
+	public void Cast_String_To_Key ()
+	{
+		var key = (Key)"Ctrl+Q";
+		Assert.Equal (KeyCode.Q | KeyCode.CtrlMask, key.KeyCode);
+	}
+
+	[Fact]
+	public void Cast_Key_ToString ()
+	{
+		var str = (string)Key.Q.WithCtrl;
+		Assert.Equal ("Ctrl+Q", str);
+	}
+
 	// IsValid
 	// IsValid
 	[Theory]
 	[Theory]
 	[InlineData (KeyCode.A, true)]
 	[InlineData (KeyCode.A, true)]
@@ -64,6 +184,28 @@ public class KeyTests {
 		Assert.Equal (expected.ToString (), key.ToString ());
 		Assert.Equal (expected.ToString (), key.ToString ());
 	}
 	}
 
 
+	[Fact]
+	public void Standard_Keys_Always_New ()
+	{
+		// Make two local keys, and grab Key.A, which is a reference to a singleton.
+		Key aKey1 = Key.A;
+		Key aKey2 = Key.A;
+
+		// Assert the starting state that is expected
+		Assert.False (aKey1.Handled);
+		Assert.False (aKey2.Handled);
+		Assert.False (Key.A.Handled);
+
+		// Now set Handled true on one of our local keys
+		aKey1.Handled = true;
+
+		// Assert the newly-expected case
+		// The last two assertions will fail, because we have actually modified a singleton
+		Assert.True (aKey1.Handled);
+		Assert.False (aKey2.Handled);
+		Assert.False (Key.A.Handled);
+	}
+
 	[Theory]
 	[Theory]
 	[InlineData ((KeyCode)'a', true)]
 	[InlineData ((KeyCode)'a', true)]
 	[InlineData ((KeyCode)'a' | KeyCode.ShiftMask, true)]
 	[InlineData ((KeyCode)'a' | KeyCode.ShiftMask, true)]
@@ -96,7 +238,7 @@ public class KeyTests {
 	[InlineData ((KeyCode)'ç' | KeyCode.ShiftMask | KeyCode.AltMask | KeyCode.CtrlMask, '\0')]
 	[InlineData ((KeyCode)'ç' | KeyCode.ShiftMask | KeyCode.AltMask | KeyCode.CtrlMask, '\0')]
 	[InlineData ((KeyCode)'a', 97)] // 97 or Key.Space | Key.A
 	[InlineData ((KeyCode)'a', 97)] // 97 or Key.Space | Key.A
 	[InlineData ((KeyCode)'A', 97)] // 65 or equivalent to Key.A, but A-Z are mapped to lower case by drivers
 	[InlineData ((KeyCode)'A', 97)] // 65 or equivalent to Key.A, but A-Z are mapped to lower case by drivers
-	//[InlineData (Key.A, 97)] // 65 equivalent to (Key)'A', but A-Z are mapped to lower case by drivers
+					//[InlineData (Key.A, 97)] // 65 equivalent to (Key)'A', but A-Z are mapped to lower case by drivers
 	[InlineData (KeyCode.ShiftMask | KeyCode.A, 65)]
 	[InlineData (KeyCode.ShiftMask | KeyCode.A, 65)]
 	[InlineData (KeyCode.CtrlMask | KeyCode.A, '\0')]
 	[InlineData (KeyCode.CtrlMask | KeyCode.A, '\0')]
 	[InlineData (KeyCode.AltMask | KeyCode.A, '\0')]
 	[InlineData (KeyCode.AltMask | KeyCode.A, '\0')]
@@ -263,14 +405,6 @@ public class KeyTests {
 	[InlineData (KeyCode.ShiftMask | KeyCode.AltMask | KeyCode.Null, "Null")]
 	[InlineData (KeyCode.ShiftMask | KeyCode.AltMask | KeyCode.Null, "Null")]
 	[InlineData (KeyCode.AltMask | KeyCode.CtrlMask | KeyCode.Null, "Null")]
 	[InlineData (KeyCode.AltMask | KeyCode.CtrlMask | KeyCode.Null, "Null")]
 	[InlineData (KeyCode.ShiftMask | KeyCode.CtrlMask | KeyCode.AltMask | KeyCode.Null, "Null")]
 	[InlineData (KeyCode.ShiftMask | KeyCode.CtrlMask | KeyCode.AltMask | KeyCode.Null, "Null")]
-	[InlineData (KeyCode.Null, "Null")]
-	[InlineData (KeyCode.ShiftMask | KeyCode.Null, "Null")]
-	[InlineData (KeyCode.CtrlMask | KeyCode.Null, "Null")]
-	[InlineData (KeyCode.AltMask | KeyCode.Null, "Null")]
-	[InlineData (KeyCode.ShiftMask | KeyCode.CtrlMask | KeyCode.Null, "Null")]
-	[InlineData (KeyCode.ShiftMask | KeyCode.AltMask | KeyCode.Null, "Null")]
-	[InlineData (KeyCode.AltMask | KeyCode.CtrlMask | KeyCode.Null, "Null")]
-	[InlineData (KeyCode.ShiftMask | KeyCode.CtrlMask | KeyCode.AltMask | KeyCode.Null, "Null")]
 	[InlineData (KeyCode.AltKey, "AltKey")]
 	[InlineData (KeyCode.AltKey, "AltKey")]
 	[InlineData (KeyCode.CtrlKey, "CtrlKey")]
 	[InlineData (KeyCode.CtrlKey, "CtrlKey")]
 	[InlineData (KeyCode.ShiftKey, "ShiftKey")]
 	[InlineData (KeyCode.ShiftKey, "ShiftKey")]

+ 1 - 1
UnitTests/Views/AppendAutocompleteTests.cs

@@ -26,7 +26,7 @@ public class AppendAutocompleteTests {
 		tf.PositionCursor ();
 		tf.PositionCursor ();
 		TestHelpers.AssertDriverContentsAre ("", output);
 		TestHelpers.AssertDriverContentsAre ("", output);
 
 
-		tf.NewKeyDownEvent ('f');
+		tf.NewKeyDownEvent (new ('f'));
 
 
 		tf.Draw ();
 		tf.Draw ();
 		tf.PositionCursor ();
 		tf.PositionCursor ();