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

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



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

Reader Comments

Comment on this Blog Post

Recent Posts

EBTCalc Users: A Desktop Version is Now Available!October 25, 2019
Python Script to Audit MediaMonkey TranscodingAugust 15, 2019
How to decompile Java code with JetBrains IntelliJ IDEA (2018.2.3, Windows 10)October 5, 2018
Java Programming Tip: SWT Photo Frame ProgramOctober 31, 2016
Vault 3 (Desktop) Version 1.63 ReleasedSeptember 9, 2016
"Compliance with Court Orders Act of 2016"April 9, 2016
Disable "Visual Voicemail" on Android / T-MobileJanuary 17, 2016