Powershell wait for input

broken image
broken image
broken image

You can’t detect pressed modifier keys alone, so you can’t figure out whether Ctrl is currently pressed. You may want to test for yourself: run the code above in a PowerShell console and in VSCode and notice the different behavior). VSCode keeps an interactive console in the background which makes reading input from the console possible but somewhat unreliable: VSCode will always echo the pressed key and seems to ignore the modifier key Alt. ISE has no interactive console, so reading keys via the console API won’t work at all. Detecting key presses via the console API is straight-forward and requires only a few lines of code, but it also has severe limitations: