-
Notifications
You must be signed in to change notification settings - Fork 511
Implement $Host.UI.RawUI.ReadKey() #1403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
With improvements to the terminal in the June 18 release of VSCode and talks about dropping older version support, I think they may have been holding back the integrated terminal and this would be fixed over time automatically. |
@TheIncorrigible1 not quite. The VSCode extension uses a custom host in the PowerShell Integrated Console and that's something we maintain. It's not as feature-rich as powershell.exe's host. So this is on us to implement and we haven't gotten to it. @SeeminglyScience also mentioned that replicating the exact functionality will be difficult because |
P.S. Thanks for commenting on a few issues :) appreciate that 👍 |
Hmm, in VSCode I'm not sure that it will be possible to get the same behavior at all. Out of curiosity I pulled the When holding down a key conhost acts differently than xterm. Doing something like this: while ($true) {
$Host.UI.RawUI.ReadKey('IncludeKeyUp, IncludeKeyDown')
} If you hold down a key while the above is running, conhost will report only key down until you release the key. xterm.js on the other hand will return both a key down and key up for every repeated character. I'm guessing this is a limitation of node-pty. Side note: We should probably save the We could even use that to implement this method, though I doubt it would obey pipeline stop requests. |
Hey @Tyriar sorry to bring you into this. I was wondering if you have any context to what @SeeminglyScience was saying. |
The issue is you don't get individual keyup and keydown events? VT doesn't communicate keyup/keydown events, just key events. This may be something lost in translation going from the verbose Windows Console API to VT. |
Thanks @Tyriar! @SeeminglyScience, I think we probably need to bring this up in the PowerShell repo so we have a consistent story across OS's and terminals. I wonder if it's worth having the same functionality (aka key event) on all OS's and terminals - then have a flag to get legacy functionality if we're in a Windows Console API-based environment. @SteveL-MSFT + @joeyaiello any thoughts? |
Even PowerShell Core console host has this difference where on Windows, you can get the individual key up/down signals, while on non-Windows, you only get the key down. I don't think VSCode-PS needs to do anything different here. |
I think we can close this now. As for the behavior, it's out of our power. It's really out of PowerShell's power too. It depends on the pty layer (it seems). conhost can read key up and key down and really any terminal on non-Windows can only read key down. |
Implement $Host.UI.RawUI.ReadKey() to read one key from the keyboard.
Today Read-Host makes you press two keys.
[Console]::ReadKey() is a workaround, but which is the "proper" way to read a key input from the user?
The text was updated successfully, but these errors were encountered: