tag:blogger.com,1999:blog-7615374417555290262.post9032784569771694153..comments2024-03-17T22:47:54.364-07:00Comments on Jason Yoder, MCT: Is there an ESCAPE key in Powershell?Jason Yoder, MCThttp://www.blogger.com/profile/04358685907523997842noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-7615374417555290262.post-49616455178871104092011-09-09T11:38:32.923-07:002011-09-09T11:38:32.923-07:00Whoops... actually, this works much better:
if ($...Whoops... actually, this works much better:<br /><br />if ($x.VirtualKeyCode -eq 27) {write-host "esc was pressed"}Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7615374417555290262.post-68387932914059153022011-09-09T11:28:37.967-07:002011-09-09T11:28:37.967-07:00Nevermind, I found it. This is it:
$x = $host.UI....Nevermind, I found it. This is it:<br /><br />$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")<br />if ($x -eq [char]27) {Write-host "esc was pressed"}Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7615374417555290262.post-9768388261630264342011-09-09T11:16:57.028-07:002011-09-09T11:16:57.028-07:00Do you know how to detect when the user presses th...Do you know how to detect when the user presses the Esc key on their keyboard using the following?<br /><br />$host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")Anonymousnoreply@blogger.com