Provides extension methods for System.ConsoleKeyInfo to evaluate specific key combinations, including standard keys and Emacs-style shortcuts.
public static class ConsoleKeyInfoExtensionsInheritance System.Object → ConsoleKeyInfoExtensions
Determines whether the Alt+B (backward word) Emacs shortcut was pressed.
public static bool IsBackwardWord(this System.ConsoleKeyInfo keyinfo);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
System.Boolean
true if Alt+B was pressed; otherwise, false.
Determines whether the Alt+C (capitalize over cursor) Emacs shortcut was pressed.
public static bool IsCapitalizeOverCursor(this System.ConsoleKeyInfo keyinfo);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
System.Boolean
true if Alt+C was pressed; otherwise, false.
Determines whether the Control+K (clear after cursor) Emacs shortcut was pressed.
public static bool IsClearAfterCursor(this System.ConsoleKeyInfo keyinfo);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
System.Boolean
true if Control+K was pressed; otherwise, false.
Determines whether the Control+U (clear before cursor) Emacs shortcut was pressed.
public static bool IsClearBeforeCursor(this System.ConsoleKeyInfo keyinfo);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
System.Boolean
true if Control+U was pressed; otherwise, false.
Determines whether the Control+L (clear content) Emacs shortcut was pressed.
public static bool IsClearContent(this System.ConsoleKeyInfo keyinfo);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
System.Boolean
true if Control+L was pressed; otherwise, false.
Determines whether the Control+D (clear word after cursor) Emacs shortcut was pressed.
public static bool IsClearWordAfterCursor(this System.ConsoleKeyInfo keyinfo);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
System.Boolean
true if Control+D was pressed; otherwise, false.
Determines whether the Control+W (clear word before cursor) Emacs shortcut was pressed.
public static bool IsClearWordBeforeCursor(this System.ConsoleKeyInfo keyinfo);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
System.Boolean
true if Control+W was pressed; otherwise, false.
Determines whether the Alt+F (forward word) Emacs shortcut was pressed.
public static bool IsForwardWord(this System.ConsoleKeyInfo keyinfo);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
System.Boolean
true if Alt+F was pressed; otherwise, false.
Determines whether the Alt+L (lower-case word) Emacs shortcut was pressed.
public static bool IsLowersCurrentWord(this System.ConsoleKeyInfo keyinfo);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
System.Boolean
true if Alt+L was pressed; otherwise, false.
Determines whether Alt+Spacebar was pressed.
public static bool IsPressAltSpaceKey(this System.ConsoleKeyInfo keyinfo);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
System.Boolean
true if Alt+Spacebar was pressed; otherwise, false.
Determines whether the Alt+Tab key was pressed.
public static bool IsPressAltTabKey(this System.ConsoleKeyInfo keyinfo);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
System.Boolean
true if Alt+Tab was pressed; otherwise, false.
Determines whether Backspace or (optionally) Control+H (Emacs delete previous character) was pressed.
public static bool IsPressBackspaceKey(this System.ConsoleKeyInfo keyinfo, bool emacskeys=true);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
emacskeys System.Boolean
If true, also accepts Control+H.
System.Boolean
true if Backspace (or Emacs equivalent) was pressed; otherwise, false.
Determines whether the key represents a "collapse" action for tree controls.
public static bool IsPressCollapseKey(this System.ConsoleKeyInfo keyinfo);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
System.Boolean
true for Numpad Minus or '-' character; otherwise, false.
Determines whether Control+Alt+Spacebar was pressed.
public static bool IsPressCtrlAltSpaceKey(this System.ConsoleKeyInfo keyinfo);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
System.Boolean
true if Control+Alt+Spacebar was pressed; otherwise, false.
Determines whether the Ctrl+Alt+Tab key was pressed.
public static bool IsPressCtrlAltTabKey(this System.ConsoleKeyInfo keyinfo);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
System.Boolean
true if Ctrl+Alt+Tab was pressed; otherwise, false.
Determines whether Control+Delete (clear word after cursor) was pressed.
public static bool IsPressCtrlDeleteKey(this System.ConsoleKeyInfo keyinfo);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
System.Boolean
true if Control+Delete was pressed; otherwise, false.
Determines whether Control+End was pressed.
public static bool IsPressCtrlEndKey(this System.ConsoleKeyInfo keyinfo);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
System.Boolean
true if Control+End was pressed; otherwise, false.
Determines whether Control+Home was pressed.
public static bool IsPressCtrlHomeKey(this System.ConsoleKeyInfo keyinfo);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
System.Boolean
true if Control+Home was pressed; otherwise, false.
Determines whether Control+Spacebar was pressed.
public static bool IsPressCtrlSpaceKey(this System.ConsoleKeyInfo keyinfo);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
System.Boolean
true if Control+Spacebar was pressed; otherwise, false.
Determines whether the Ctrl+Tab key was pressed.
public static bool IsPressCtrlTabKey(this System.ConsoleKeyInfo keyinfo);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
System.Boolean
true if Ctrl+Tab was pressed; otherwise, false.
Determines whether Delete or (optionally) Control+D (Emacs delete forward) was pressed.
public static bool IsPressDeleteKey(this System.ConsoleKeyInfo keyinfo, bool emacskeys=true);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
emacskeys System.Boolean
If true, also accepts Control+D.
System.Boolean
true if Delete (or Emacs equivalent) was pressed; otherwise, false.
Determines whether DownArrow or (optionally) Control+N (Emacs next line/history) was pressed.
public static bool IsPressDownArrowKey(this System.ConsoleKeyInfo keyinfo, bool emacskeys=true);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
emacskeys System.Boolean
If true, also accepts Control+N.
System.Boolean
true if DownArrow (or Emacs equivalent) was pressed; otherwise, false.
Determines whether End or (optionally) Control+E (Emacs end-of-line) was pressed.
public static bool IsPressEndKey(this System.ConsoleKeyInfo keyinfo, bool emacskeys=true);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
emacskeys System.Boolean
If true, also accepts Control+E.
System.Boolean
true if End (or Emacs equivalent) was pressed; otherwise, false.
Determines whether the pressed key represents an Enter action.
public static bool IsPressEnterKey(this System.ConsoleKeyInfo keyinfo, bool emacskeys=true);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
emacskeys System.Boolean
If true, also accepts Control+J as Enter (Emacs style).
System.Boolean
true if Enter (or accepted Emacs equivalent) was pressed; otherwise, false.
On non-Windows platforms both CR (13) and LF (10) may be emitted. This method normalizes those cases.
Determines whether Escape (without modifiers) was pressed.
public static bool IsPressEscKey(this System.ConsoleKeyInfo keyinfo);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
System.Boolean
true if Escape was pressed; otherwise, false.
Determines whether the key represents an "expand" action for tree controls.
public static bool IsPressExpandKey(this System.ConsoleKeyInfo keyinfo);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
System.Boolean
true for Numpad Plus or '+' character; otherwise, false.
Determines whether the cross-terminal filter activation key was pressed.
public static bool IsPressFilterActivationKey(this System.ConsoleKeyInfo keyinfo);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
System.Boolean
true for Ctrl+Alt+Spacebar (primary) or Ctrl+Spacebar (fallback for terminals
that do not report Ctrl+Alt+Spacebar consistently); otherwise, false.
Determines whether Home or (optionally) Control+A (Emacs beginning-of-line) was pressed.
public static bool IsPressHomeKey(this System.ConsoleKeyInfo keyinfo, bool emacskeys=true);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
emacskeys System.Boolean
If true, also accepts Control+A.
System.Boolean
true if Home (or Emacs equivalent) was pressed; otherwise, false.
Determines whether LeftArrow or (optionally) Control+B (Emacs move backward) was pressed.
public static bool IsPressLeftArrowKey(this System.ConsoleKeyInfo keyinfo, bool emacskeys=true);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
emacskeys System.Boolean
If true, also accepts Control+B.
System.Boolean
true if LeftArrow (or Emacs equivalent) was pressed; otherwise, false.
Determines whether PageDown or (optionally) Alt+N (Emacs next extended navigation) was pressed.
public static bool IsPressPageDownKey(this System.ConsoleKeyInfo keyinfo, bool emacskeys=true);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
emacskeys System.Boolean
If true, also accepts Alt+N.
System.Boolean
true if PageDown (or Emacs equivalent) was pressed; otherwise, false.
Determines whether PageUp or (optionally) Alt+P (Emacs previous extended navigation) was pressed.
public static bool IsPressPageUpKey(this System.ConsoleKeyInfo keyinfo, bool emacskeys=true);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
emacskeys System.Boolean
If true, also accepts Alt+P.
System.Boolean
true if PageUp (or Emacs equivalent) was pressed; otherwise, false.
Determines whether RightArrow or (optionally) Control+F (Emacs move forward) was pressed.
public static bool IsPressRightArrowKey(this System.ConsoleKeyInfo keyinfo, bool emacskeys=true);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
emacskeys System.Boolean
If true, also accepts Control+F.
System.Boolean
true if RightArrow (or Emacs equivalent) was pressed; otherwise, false.
Determines whether Shift+Tab was pressed.
public static bool IsPressShiftTabKey(this System.ConsoleKeyInfo keyinfo);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
System.Boolean
true if Shift+Tab was pressed; otherwise, false.
Determines whether Spacebar (without modifiers) was pressed.
public static bool IsPressSpaceKey(this System.ConsoleKeyInfo keyinfo);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
System.Boolean
true if Spacebar was pressed; otherwise, false.
ConsoleKeyInfoExtensions.IsPressSpecialKey(this ConsoleKeyInfo, ConsoleKey, ConsoleModifiers) Method
Determines whether the pressed key matches the specified key and modifier.
public static bool IsPressSpecialKey(this System.ConsoleKeyInfo keyinfo, System.ConsoleKey key, System.ConsoleModifiers modifier);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
The expected System.ConsoleKey.
modifier System.ConsoleModifiers
The expected System.ConsoleModifiers.
System.Boolean
true if both key and modifier match; otherwise, false.
Determines whether the Tab key (without modifiers) was pressed.
public static bool IsPressTabKey(this System.ConsoleKeyInfo keyinfo);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
System.Boolean
true if Tab was pressed; otherwise, false.
Determines whether UpArrow or (optionally) Control+P (Emacs previous line/history) was pressed.
public static bool IsPressUpArrowKey(this System.ConsoleKeyInfo keyinfo, bool emacskeys=true);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
emacskeys System.Boolean
If true, also accepts Control+P.
System.Boolean
true if UpArrow (or Emacs equivalent) was pressed; otherwise, false.
Determines whether the Control+T (transpose previous characters) Emacs shortcut was pressed.
public static bool IsTransposePrevious(this System.ConsoleKeyInfo keyinfo);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
System.Boolean
true if Control+T was pressed; otherwise, false.
Determines whether the Alt+U (upper-case word) Emacs shortcut was pressed.
public static bool IsUppersCurrentWord(this System.ConsoleKeyInfo keyinfo);keyinfo System.ConsoleKeyInfo
The System.ConsoleKeyInfo to evaluate.
System.Boolean
true if Alt+U was pressed; otherwise, false.