Skip to content

Document KeyPreview exceptions and keyboard interception guidance for WinForms#2254

Open
adegeo wants to merge 7 commits into
mainfrom
winforms/2235/keyboard
Open

Document KeyPreview exceptions and keyboard interception guidance for WinForms#2254
adegeo wants to merge 7 commits into
mainfrom
winforms/2235/keyboard

Conversation

@adegeo

@adegeo adegeo commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Fixes #2235

  • Added "When KeyPreview is not enough" section to how-to-handle-forms.md covering preprocessing exceptions and a ProcessCmdKey override example.
  • Added a quick decision guide table to overview.md for choosing the right keyboard interception API.
  • Added "Form-level keyboard input limitations" section to overview.md with a cross-link to the new exceptions section.
  • Fixed a punctuation artifact in the overview.md preprocessing table.
  • Fixed incorrect WPF type reference in validation.md.
  • Added a locale-sensitivity caution to the SendKeys example in how-to-simulate-events.md.
  • Updated how-to-handle-forms snippets to use readable character literals instead of numeric char codes.

Internal previews

📄 File 🔗 Preview link
dotnet-desktop-guide/winforms/input-keyboard/how-to-change-key-press.md dotnet-desktop-guide/winforms/input-keyboard/how-to-change-key-press
dotnet-desktop-guide/winforms/input-keyboard/how-to-check-modifier-key.md dotnet-desktop-guide/winforms/input-keyboard/how-to-check-modifier-key
dotnet-desktop-guide/winforms/input-keyboard/how-to-handle-forms.md dotnet-desktop-guide/winforms/input-keyboard/how-to-handle-forms
dotnet-desktop-guide/winforms/input-keyboard/how-to-simulate-events.md dotnet-desktop-guide/winforms/input-keyboard/how-to-simulate-events
dotnet-desktop-guide/winforms/input-keyboard/overview.md dotnet-desktop-guide/winforms/input-keyboard/overview
dotnet-desktop-guide/winforms/input-keyboard/validation.md dotnet-desktop-guide/winforms/input-keyboard/validation

Copilot AI review requested due to automatic review settings July 2, 2026 19:53
@adegeo adegeo changed the title Fix issue Document KeyPreview exceptions and keyboard interception guidance for WinForms Jul 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Windows Forms keyboard input docs to better explain why KeyPreview doesn’t catch some keys (notably keys handled during preprocessing), and it refreshes related snippets and references.

Changes:

  • Added a new “When KeyPreview is not enough” section that explains preprocessing exceptions and shows a ProcessCmdKey override example.
  • Added a quick decision guide and a form-level limitations note to the keyboard input overview.
  • Updated snippets (readability improvements, SendKeys sequences), plus fixed a WinForms/WPF type reference and refreshed dates.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
dotnet-desktop-guide/winforms/input-keyboard/validation.md Fixes an incorrect WPF TextBox reference to the WinForms TextBox, and updates ms.date.
dotnet-desktop-guide/winforms/input-keyboard/overview.md Adds a keyboard interception decision table, clarifies form-level limitations, and fixes a punctuation artifact.
dotnet-desktop-guide/winforms/input-keyboard/how-to-simulate-events.md Adds a caution about locale-sensitive window title lookup.
dotnet-desktop-guide/winforms/input-keyboard/how-to-handle-forms.md Adds a section explaining preprocessing exceptions and links to ProcessCmdKey examples.
dotnet-desktop-guide/winforms/input-keyboard/snippets/how-to-simulate-events/vb/projectvb.vbproj Updates snippet project TFM to net10.0-windows.
dotnet-desktop-guide/winforms/input-keyboard/snippets/how-to-simulate-events/vb/Form1.vb Updates SendKeys sequence to match the intended shortcut.
dotnet-desktop-guide/winforms/input-keyboard/snippets/how-to-simulate-events/csharp/project.csproj Updates snippet project TFM to net10.0-windows.
dotnet-desktop-guide/winforms/input-keyboard/snippets/how-to-simulate-events/csharp/Form1.cs Updates SendKeys sequence to match the intended shortcut.
dotnet-desktop-guide/winforms/input-keyboard/snippets/how-to-handle-forms/vb/projectvb.vbproj Updates snippet project TFM to net10.0-windows.
dotnet-desktop-guide/winforms/input-keyboard/snippets/how-to-handle-forms/vb/Form1.vb Improves digit detection/readability, and adds a ProcessCmdKey override snippet.
dotnet-desktop-guide/winforms/input-keyboard/snippets/how-to-handle-forms/csharp/project.csproj Updates snippet project TFM to net10.0-windows.
dotnet-desktop-guide/winforms/input-keyboard/snippets/how-to-handle-forms/csharp/Form1.cs Improves digit detection/readability, and adds a ProcessCmdKey override snippet.

Comment thread dotnet-desktop-guide/winforms/input-keyboard/how-to-handle-forms.md Outdated
adegeo and others added 2 commits July 2, 2026 13:26
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment thread dotnet-desktop-guide/winforms/input-keyboard/how-to-handle-forms.md Outdated
Comment thread dotnet-desktop-guide/winforms/input-keyboard/how-to-simulate-events.md Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace %2A with * in this file.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace %2A with * in this file.

adegeo and others added 3 commits July 2, 2026 15:38
Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
@adegeo adegeo enabled auto-merge (squash) July 2, 2026 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Documentation does not mention the exceptions

3 participants