共用方式為


PSHostRawUserInterface.ReadKey Method

Definition

Overloads

ReadKey()

Reads a key stroke from the keyboard device, blocking until a keystroke is typed. Same as ReadKey(ReadKeyOptions.IncludeKeyDown)

ReadKey(ReadKeyOptions)

Reads a key stroke from the keyboard device, blocking until a keystroke is typed. Either one of ReadKeyOptions.IncludeKeyDown and ReadKeyOptions.IncludeKeyUp or both must be specified.

ReadKey()

Reads a key stroke from the keyboard device, blocking until a keystroke is typed. Same as ReadKey(ReadKeyOptions.IncludeKeyDown)

public:
 System::Management::Automation::Host::KeyInfo ReadKey();
public System.Management.Automation.Host.KeyInfo ReadKey ();
member this.ReadKey : unit -> System.Management.Automation.Host.KeyInfo
Public Function ReadKey () As KeyInfo

Returns

Key stroke when a key is pressed.

Examples

$Host.UI.RawUI.ReadKey()

See also

Applies to

ReadKey(ReadKeyOptions)

Reads a key stroke from the keyboard device, blocking until a keystroke is typed. Either one of ReadKeyOptions.IncludeKeyDown and ReadKeyOptions.IncludeKeyUp or both must be specified.

public:
 abstract System::Management::Automation::Host::KeyInfo ReadKey(System::Management::Automation::Host::ReadKeyOptions options);
public abstract System.Management.Automation.Host.KeyInfo ReadKey (System.Management.Automation.Host.ReadKeyOptions options);
abstract member ReadKey : System.Management.Automation.Host.ReadKeyOptions -> System.Management.Automation.Host.KeyInfo
Public MustOverride Function ReadKey (options As ReadKeyOptions) As KeyInfo

Parameters

options
ReadKeyOptions

A bit mask of the options to be used to read the keyboard. Constants defined by ReadKeyOptions

Returns

Key stroke depending on the value of options.

Exceptions

Neither ReadKeyOptions.IncludeKeyDown nor ReadKeyOptions.IncludeKeyUp is specified.

Examples

$option = [System.Management.Automation.Host.ReadKeyOptions]"IncludeKeyDown";
$host.UI.RawUI.ReadKey($option)

See also

Applies to