← Back to Home • Next: Confirm — Styles →
Confirm runs on the same engine as KeyPress, so its runtime behavior —
the single-keystroke wait, valid-key matching, invalid-key message, tooltip, and abort — is exactly
the same. This page notes only what is specific to the yes/no preset and links to the shared
reference on KeyPress → Operations.
Apply changes? (Y/N) ← prompt — Confirm always appends " (Yes/No key)" itself
Press the culture-specific Yes/No key ← description (optional)
Esc:Abort.Ctrl+F1:Show/hide tooltip ← tooltip — does NOT list the valid Y/N keys, only hints
Every region can be recolored — see Styles.
Confirm calls the KeyPress engine with the current culture's Yes and No keys already registered as valid keys. Consequences:
- Only the Yes key and the No key end the wait; any other key is rejected (and shows the invalid-key message if one is configured).
- The specific letters depend on the active culture. In
en-USthey are Y/N; switchingPromptPlus.Config.DefaultCultureto, say,pt-BRswitches them to that culture's letters. PromptPlus.Config.YesChar/NoCharexpose the active pair, which is how you interpret the result (see Index).Confirm(...)automatically appends" ({yesKey}/{noKey})"to whatever prompt text you pass — e.g.Confirm("Apply changes?")renders asApply changes? (Y/N). You don't need to (and shouldn't) add this hint yourself.
You can still register extra keys with AddValidKey; they
are accepted in addition to Yes/No.
Everything below works identically to KeyPress — follow the links for the details:
| Behavior | Reference |
|---|---|
| Single-keystroke wait (returns on the first accepted key) | KeyPress → Single-keystroke wait |
| Valid-key restriction (accumulates; Yes/No are pre-set here) | KeyPress → Valid-key restriction |
| Invalid-key message | KeyPress → Invalid-key message |
| Tooltip (F1 / Ctrl+F1) | KeyPress → Tooltip |
Abort (Esc → .IsAborted, no .Content value) |
KeyPress → Abort |
Options overrides |
KeyPress → Options that change behavior |
The result is a ConsoleKeyInfo?, not a bool. Compare the pressed character to the Yes char:
var confirm = PromptPlus.Controls.Confirm("Continue?").Run();
if (!confirm.IsAborted &&
confirm.Content is { } k &&
char.ToUpperInvariant(k.KeyChar) == char.ToUpperInvariant(PromptPlus.Config.YesChar))
{
// Yes
}Branch on .IsAborted first — an aborted confirm carries no .Content value and is neither yes nor
no.
- KeyPress → Operations — the complete runtime reference
- Index — the yes/no pattern and return-value interpretation
- Methods — the shared API
- Global Behaviors —
YesChar,NoChar,DefaultCulture