diff --git a/src/Surface.zig b/src/Surface.zig
index c3fd1e9d4..575a7e822 100644
--- a/src/Surface.zig
+++ b/src/Surface.zig
@@ -145,6 +145,7 @@ const DerivedConfig = struct {
mouse_shift_capture: configpkg.MouseShiftCapture,
macos_non_native_fullscreen: configpkg.NonNativeFullscreen,
macos_option_as_alt: configpkg.OptionAsAlt,
+ vt_kam_allowed: bool,
window_padding_x: u32,
window_padding_y: u32,
@@ -166,6 +167,7 @@ const DerivedConfig = struct {
.mouse_shift_capture = config.@"mouse-shift-capture",
.macos_non_native_fullscreen = config.@"macos-non-native-fullscreen",
.macos_option_as_alt = config.@"macos-option-as-alt",
+ .vt_kam_allowed = config.@"vt-kam-allowed",
.window_padding_x = config.@"window-padding-x",
.window_padding_y = config.@"window-padding-y",
@@ -985,6 +987,13 @@ pub fn keyCallback(
if (consumed and performed) return true;
}
+ // If we allow KAM and KAM is enabled then we do nothing.
+ if (self.config.vt_kam_allowed) {
+ self.renderer_state.mutex.lock();
+ defer self.renderer_state.mutex.unlock();
+ if (self.io.terminal.modes.get(.disable_keyboard)) return true;
+ }
+
// If this input event has text, then we hide the mouse if configured.
if (self.config.mouse_hide_while_typing and
!self.mouse.hidden and
diff --git a/src/config/Config.zig b/src/config/Config.zig
index c21564f42..82733bfba 100644
--- a/src/config/Config.zig
+++ b/src/config/Config.zig
@@ -461,6 +461,14 @@ keybind: Keybinds = .{},
/// The default value is "16-bit".
@"osc-color-report-format": OSCColorReportFormat = .@"16-bit",
+/// If true, allows the "KAM" mode (ANSI mode 2) to be used within
+/// the terminal. KAM disables keyboard input at the request of the
+/// application. This is not a common feature and is not recommended
+/// to be enabled. This will not be documented further because
+/// if you know you need KAM, you know. If you don't know if you
+/// need KAM, you don't need it.
+@"vt-kam-allowed": bool = false,
+
/// If anything other than false, fullscreen mode on macOS will not use the
/// native fullscreen, but make the window fullscreen without animations and
/// using a new space. It's faster than the native fullscreen mode since it
diff --git a/src/terminal/modes.zig b/src/terminal/modes.zig
index 25a020e9d..8c49941ba 100644
--- a/src/terminal/modes.zig
+++ b/src/terminal/modes.zig
@@ -170,6 +170,7 @@ const ModeEntry = struct {
/// valuable to redocument them all here.
const entries: []const ModeEntry = &.{
// ANSI
+ .{ .name = "disable_keyboard", .value = 2, .ansi = true }, // KAM
.{ .name = "insert", .value = 4, .ansi = true },
// DEC
diff --git a/website/app/vt/modes/kam/page.mdx b/website/app/vt/modes/kam/page.mdx
new file mode 100644
index 000000000..3efeca79c
--- /dev/null
+++ b/website/app/vt/modes/kam/page.mdx
@@ -0,0 +1,28 @@
+import VTMode from "@/components/VTMode";
+
+# Keyboard Action Mode (KAM)
+
+