Eric Bergman-Terrell's Blog

Previous Blog Post PowerShell Tip: Prompt the User for a Key Press Next Blog Post
August 21, 2011

How to prompt the user to type a particular key, and pause until that key is typed:

function Pause($Message)
{
Write-Host -NoNewLine $Message

do
{
$key = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
} while ($key.Character -ne 'Q')

Write-Host
}

...

Pause "Script Finished. Press Q to quit."
Keywords: PowerShell, Prompt, Key, Keystroke, Keypress

Reader Comments

Comment on this Blog Post

Recent Posts

Title Date
Vault 0.53 Released March 29, 2013
Vault 3 (Desktop Version) Updated March 23, 2013
EBTCalc for Android v. 1.12 - Now Runs on Phones and Smaller Tablets February 09, 2013
Vault 3 (PC Version) v. 0.50 Released January 07, 2013
Android Programming Tip: Recycle Views in Adapters December 07, 2012
Android Programming Tip: How to Embed EditText Views in a ListView (Don't!) December 07, 2012
EBTCalc for Android December 03, 2012