-
Notifications
You must be signed in to change notification settings - Fork 18k
x/sys/windows: Neither Read() nor ReadConsole() read special keys #44373
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
/cc @alexbrainman |
Here's a bit more. The old way would be to set the console mode and read from the console via the deprecated
This way I can read the arrow keys, and it works on Windows 7. See the full demo in github.com/scrouthtv/termios/win_arrows |
Found the difference: Both ways use the very same code. Except that Because of backwards compatibility, I'd suggest introducing a new method to the // ReadConsole reads characters from the console // ReadConsoleInput reads any input from the console |
Okay, both functions don't really work for me:
|
@scrouthtv and @toothrot I cannot help here. This is a question about Windows programming. And I am unfamiliar with this area of Windows. Alex |
@scrouthtv It sounds like this might be better answered if seen by more Go Windows developers, maybe on one of our forums: https://golang.org/wiki/Questions. I know that relatively few Go programmers follow issues as closely as they do the resources listed there. It sounds like this is something someone must have run into before. There still may be an issue here, but I personally lack the Windows expertise to know what it is. |
For future reference: https://forum.golangbridge.org/t/windows-raw-console-i-o/22487. Thanks for your time |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes. It also happens to me on Go 1.15.4
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I am currently writing a simple command-line editor in Go. For this, I want my program to be able to read every of the user's keypresses. For this, I think I have to set the Console Mode to only
ENABLE_WINDOW_INPUT
.Here is my code (sorry for inline code, I think Go Playground is not really applicable):
What did you expect to see?
I'd expect this program to start, and close after I pressed an arrow key.
What did you see instead?
The program starts, but does only exit if I press a letter key (a-z, 0-9). Special keys as F1 through F12, the arrow keys or home/end/pgup/pgdown don't work.
If I set the console mode to
ENABLE_WINDOW_INPUT | ENABLE_VIRTUAL_TERMINAL_INPUT
instead, the behaviour is as expected, but then I don't have support on older Windows devices (7, 8, ...)Thanks for any help in advance.
The text was updated successfully, but these errors were encountered: