-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Send a KeyUp sequence only once a key has been released #15130
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems right to me, but does the test case in #4192 still work? That was the initial reason to return false there...
To add to Leonard's question, does this have any impact on This is less about this PR, but I did think of it: f an application requests Win32 input mode from conhost and forceVT is on in Terminal, does conhost synthesize weird events? Does VT input passthrough via conpty work if Terminal is in win32 input mode and the client app requests win32 as well? |
@lhecker If you mean a custom keyboard layout with dead keys mapping to themselves, I have definitely not tried that. I suspect it might still work, because the key down events should still be the same. However, the key up events would assumedly now be different, but I'm not sure that matters, given the conhost already sends key up events in a somewhat random manner. I have tried your
@DHowett I've just tested now, and it doesn't appear to affect that in any way.
Yes. Basic printable characters seems reasonable, except obviously you get the key up events immediately, because it doesn't know any better. Things like arrow keys and function keys are weird, since they are received as a bunch of keypresses representing the VT escape sequence, which isn't ideal. But that's no different from how it worked before.
I'm not sure what you're asking here. If you haven't set the |
I've tested the custom AZERTY-NF keyboard now, and the AltGr+N,O test is still working as expected. In fact, looking at the events being generated, I think it's actually more correct than it was before. In the tables below I've listed what is seen by In the current WT implementation, you don't see the dead N key at all, while the new implementation does at least see the up event (conhost generates both down and up, but the down event has a null char). Also in the current WT implementation, both the down and up events for the generated Conhost
Windows Terminal (current)
Windows Terminal (this PR)
|
Okay, here's a thought! If you have Sorry, I could be testing this myself. Your build artifacts now contain an unpackaged distribution... just a sec |
Okay, no, it doesn't. |
Tab is actually one of the keys which already triggers the key-up event separately from the key-down, and it is possible for the key-up to be received when you Alt+Tab to the Terminal if you get your timing right (or wrong, depending on how you see it). However, as you noted, that doesn't seem to be enough to make it snap. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The write-up is longer than the change, for once! I love it!
Thanks for doing this. We tested this in a team bug bash and couldn't figure out how to explode it, so I'm gonna call it good for 1.18 Preview :)
Thanks again for all thee verification and testing it with the IME, too.
When win32-input-mode is enabled, we generate an input sequence for both
key down and key up events. However, in the initial implementation the
key up sequence for most keypresses would be faked - they were generated
at the same time as the key down sequence, regardless of when the key
was actually released. After this PR, we'll only generate the key up
sequence once a key has actually been released.
References and Relevant Issues
The initial implementation of win32-input-mode was in PR #6309.
The spec for win32-input-mode was in PR #5887.
Validation Steps Performed
I've manually tested this with an app that polls
ReadConsoleInput
in aloop and logs the results. With this PR applied, I can now see the key
up events as a key is released, rather than when it was first pressed.
When compared with conhost, though, there are some differences. When
typing a shifted key, e.g.
Shift
+A
, WT generates key down and key upevents for both the
Shift
and theA
, while conhost only generatesboth events for the
Shift
- theA
won't generate a key up eventunless you release the
Shift
before theA
. That seems more like aconhost flaw though.
Another case I tested was the Japanese Microsoft IME, which in conhost
will generate a key down event for the Japanese character being inserted
followed by a key up event for for
Return
. WT generates key up eventsfor the ASCII characters being typed in the IME, then both a key down
and key up event for the inserted Japanese character, and finally a key
up event for
Return
. Both of those seem weird, but they still appearto work OK.
The current version of WT actually produces the most sensible behavior
for the IME - it just generates key up and key down events for the
inserted character. But that's only because it's dropping most of the
system generated key up events.
Closes #8440