Skip to content
ConsoleMonster

API Reference

Class

ConsoleKeyInput

Namespace ConsoleMonster.Input
Assembly ConsoleMonster
Implements
IInputSource IDisposable
Modifiers sealed

Reads keys through Console.ReadKey, which decodes the terminal's VT input on Linux and macOS. Used where the Windows console API is not available. Pastes arrive as single characters and focus changes are not reported; resizes are detected by polling the window size.

Inheritance

  • Object
  • ConsoleKeyInput

Constructors

public ConsoleKeyInput() #

Creates the reader.

Methods

public Void Dispose() #
Returns: Void

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public static InputEvent FromKeyInfo(ConsoleKeyInfo info) #
Returns: InputEvent

Converts a .NET key record into an input event.

Parameters

info System.ConsoleKeyInfo requiredposition: 0
The key record.

Returns

The event.

public InputEvent? Read(TimeSpan timeout, CancellationToken cancellationToken) #
Returns: InputEvent?

Waits up to timeout for the next event.

Parameters

timeout System.TimeSpan requiredposition: 0
The longest wait; TimeSpan.Zero polls.
cancellationToken System.Threading.CancellationToken requiredposition: 1
Cancels the wait with OperationCanceledException.

Returns

The event, or null when the timeout passed without input.

Exceptions

Properties

public String Name { get; } #

A short description for diagnostics, for example windows console (ReadConsoleInputW).