diff --git a/Terminal.Gui/Core/Application.cs b/Terminal.Gui/Core/Application.cs
index 3d518e68f..fb9f7d483 100644
--- a/Terminal.Gui/Core/Application.cs
+++ b/Terminal.Gui/Core/Application.cs
@@ -148,6 +148,10 @@ namespace Terminal.Gui {
/// Alternative key to navigate backwards through all views. Shift+Ctrl+Tab is always used.
///
public static Key AlternateBackwardKey { get; set; } = Key.PageUp | Key.CtrlMask;
+ ///
+ /// Gets or sets the key to quit the application.
+ ///
+ public static Key QuitKey { get; set; } = Key.Q | Key.CtrlMask;
///
/// The driver for the application
diff --git a/Terminal.Gui/Core/Toplevel.cs b/Terminal.Gui/Core/Toplevel.cs
index ee4217837..2ce5084ea 100644
--- a/Terminal.Gui/Core/Toplevel.cs
+++ b/Terminal.Gui/Core/Toplevel.cs
@@ -294,7 +294,7 @@ namespace Terminal.Gui {
return true;
switch (ShortcutHelper.GetModifiersKey (keyEvent)) {
- case Key.Q | Key.CtrlMask:
+ case Key k when k == Application.QuitKey:
// FIXED: stop current execution of this container
if (Application.MdiTop != null) {
Application.MdiTop.RequestStop ();
diff --git a/UnitTests/ApplicationTests.cs b/UnitTests/ApplicationTests.cs
index 4f8d99caf..c24f95673 100644
--- a/UnitTests/ApplicationTests.cs
+++ b/UnitTests/ApplicationTests.cs
@@ -1142,5 +1142,36 @@ namespace Terminal.Gui.Core {
Assert.False (Application.ShowChild (Application.Top));
Application.End (Application.Top);
}
+
+ [Fact]
+ [AutoInitShutdown]
+ public void QuitKey_Getter_Setter ()
+ {
+ var top = Application.Top;
+ var isQuiting = false;
+
+ top.Closing += (e) => {
+ isQuiting = true;
+ e.Cancel = true;
+ };
+
+ Application.Begin (top);
+ top.Running = true;
+
+ Assert.Equal (Key.Q | Key.CtrlMask, Application.QuitKey);
+ Application.Driver.SendKeys ('q', ConsoleKey.Q, false, false, true);
+ Assert.True (isQuiting);
+
+ isQuiting = false;
+ Application.QuitKey = Key.C | Key.CtrlMask;
+
+ Application.Driver.SendKeys ('q', ConsoleKey.Q, false, false, true);
+ Assert.False (isQuiting);
+ Application.Driver.SendKeys ('c', ConsoleKey.C, false, false, true);
+ Assert.True (isQuiting);
+
+ // Reset the QuitKey to avoid throws errors on another tests
+ Application.QuitKey = Key.Q | Key.CtrlMask;
+ }
}
}