Keyboard input/Keypress check: Difference between revisions

Content added Content deleted
Line 36: Line 36:


=={{header|PowerShell}}==
=={{header|PowerShell}}==
The following uses the special <code>$Host</code> variable which points to an instance of the PowerShell host application. Since the host's capabilities may vary this may not wok in all PowerShell hosts. In particular, this works in the console host, but not in the PowerShell ISE.
The following uses the special <code>$Host</code> variable which points to an instance of the PowerShell host application. Since the host's capabilities may vary this may not work in all PowerShell hosts. In particular, this works in the console host, but not in the PowerShell ISE.
<lang powershell>if ($Host.UI.RawUI.KeyAvailable) {
<lang powershell>if ($Host.UI.RawUI.KeyAvailable) {
$key = $Host.UI.RawUI.ReadKey()
$key = $Host.UI.RawUI.ReadKey()