Skip to content
| Marketplace
Sign in
Visual Studio Code>Keymaps>AI Prompt Key GuardNew to Visual Studio Code? Get it now.
AI Prompt Key Guard

AI Prompt Key Guard

SPAjs

|
3 installs
| (0) | Free
Prevent accidental AI prompt submissions. Enter inserts a newline; a configurable modifier+Enter submits.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

AI Prompt Key Guard 🛡️

Prompted too early? Never again — Write well-structured, thoughtful prompts. Submit only when you're ready.

The Problem

You're carefully crafting a complex prompt to get the best response from your AI — multi-line, well-structured, thoughtful. You hit Enter to start a new paragraph instead of Shift+Enter, and — whoops — your half-baked thought is immediately sent. Now you're waiting for a useless response, stopping generation, and starting over. Every engineer who works in VS Code knows this pain.

The Solution

AI Prompt Key Guard acts as a safety net for your AI workflow inside VS Code. It intercepts the bare Enter key in VS Code's chat inputs, forcing it to insert a newline instead of submitting. When your prompt is fully ready, use your configured shortcut — Ctrl+Enter, Alt+Enter, or Cmd+Enter on Mac — to send it deliberately.

Also available for Chrome / Edge

Love it in VS Code? The same key guard is available as a browser extension — protecting your prompts on Gemini, Claude, Grok, ChatGPT, Copilot, and other web-based AI chat boxes.

Chrome Web Store: AI Prompt Key Guard


What It Does

Key Behaviour
Enter Inserts a newline — never submits accidentally
Shift+Enter Also inserts a newline (unchanged)
Your configured key Submits the prompt

That's it. No magic, no complexity. Write well-structured, thoughtful prompts — and submit only when you're ready.


Supported Chat Surfaces

  • ✅ GitHub Copilot Chat (panel)
  • ✅ VS Code built-in Chat (Ask / Agent mode)
  • ✅ Inline Chat (the floating box that opens mid-editor)

First Run

On first install, AI Prompt Key Guard starts ON and shows a setup wizard. You can:

  • Pick from common submit key options (with conflict warnings)
  • Stick with the default (Ctrl+Enter)
  • Dismiss and configure later

To re-open the wizard any time:

Command Palette → aiPromptKeyGuard: Run Setup Wizard

Configuration

Settings UI: File → Preferences → Settings → search "AIPromptKeyGuard"

settings.json:

{
  // Enable or disable the guard
  "aiPromptKeyGuard.enabled": true,

  // Your preferred submit key. Options:
  // "ctrl+enter"       — all platforms (default)
  // "alt+enter"        — all platforms
  // "cmd+enter"        — macOS only
  // "ctrl+shift+enter" — all platforms, safe from conflicts
  // "alt+shift+enter"  — all platforms, safe from conflicts
  "aiPromptKeyGuard.submitKey": "ctrl+enter"
}

Custom keybinding (if you want something not in the list above):

Open keybindings.json (Ctrl+Shift+P → Open Keyboard Shortcuts (JSON)) and add:

{
  "key": "your+key+combo",
  "command": "aiPromptKeyGuard.submitPrompt",
  "when": "inChatInput || inlineChatFocused || chatInputFocus"
}

Toggle On/Off

Three ways to toggle the guard:

Method How
Status bar Click the 🛡 ON / OFF badge (bottom-right)
Command Palette aiPromptKeyGuard: Toggle On/Off
Keyboard shortcut Ctrl+Shift+G (customisable via keybindings.json)

The badge turns amber when active, and goes neutral when disabled.


Known Keybinding Conflicts

AI Prompt Key Guard will warn you during setup if your chosen key is known to conflict with another common extension or VS Code built-in.

Key Potential Conflict
Ctrl+Enter Git commit (Source Control), Jupyter run cell, SQL Tools
Alt+Enter Quick Fix / Code Action picker
Cmd+Enter Git commit (macOS), Jupyter run cell (macOS)
Ctrl+Shift+Enter ✅ Generally safe
Alt+Shift+Enter ✅ Generally safe

Known Issues

Works with VS Code only

This extension intercepts keystrokes via VS Code's native keybinding system using context keys like inChatInput and inlineChatFocused. These context keys are set by VS Code's own built-in chat UI and are not available in other VS Code-based editors such as Cursor, Google Antigravity, Windsurf, or similar forks.

Those editors implement their own AI chat panels using webviews — an embedded browser context where VS Code's keybinding system cannot intercept keyboard events. This is a platform limitation, not a bug.

Workaround: Check if your editor has a native enterToSend or equivalent setting in its own preferences, which may achieve the same result.


Other AI Companion Extensions

Want To Backup Before Every AI Edit?

AI moves fast — and so do mistakes. Before letting AI touch your files, snapshot them instantly with these companion extensions. No Git required.

Never lose your progress — instantly tag your work (file / files / folder — with or without Git) before every edit, whether by you or your AI.

  • Backup File — Single file snapshots, no tags
  • Tagged File Snapshots — Single file snapshots with tags
  • Tagged Snapshots — Tagged snapshots of all open editor files / active tab group
  • Backup Folder — Full folder backup / snapshot
  • Git Snapshots — Git-based snapshots

Requirements

  • VS Code 1.90 or later
  • No dependencies

License

MIT

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft