Eric Bergman-Terrell's Blog

PowerShell Tip: Prompt the User for a Key Press
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

TitleDate
Node.js + Express: How to Block Requests by User-Agent HeadersJanuary 7, 2026
Vault 3 is Now Available for Windows on ARM Machines!December 13, 2025
Vault 3: How to Include Outline Text in Exported PhotosOctober 26, 2025
.NET Public-Key (Asymmetric) Cryptography DemoJuly 20, 2025
Raspberry Pi 3B+ Photo FrameJune 17, 2025
EBTCalc (Android) Version 1.53 is now availableMay 19, 2024
Vault 3 Security EnhancementsOctober 24, 2023