-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Win32 input make/break events are generated at the same time #8440
Comments
Yep, this is unfortunately true. Since the Terminal is using the UWP XAML Input stack, we only get three types of input events: key downs, key ups, and character received events. Since we don't get full unicode character input from just the key down/ups, we have to rely on the character events for that. But there's no character up/down events, only received. So we've got to send a fake key down/up pair immediately. I'm sure if there was a way to avoid doing this, @lhecker would have thought of it by now 😜 For the sake of linking: #4999 dealt with a lot of similar issues. At least conpty is now capable of theoretically handling this, if only the Terminal was. |
We could integrate the UWP based WT more deeply with our Win32 entrypoint. |
I've renamed this and iceboxed it. There's some ways in which we'll want to be compatible with the console, and a great many in which we will not. This one requires enough work (and subversion of the "modern" input stack) that I would bin it into the "not" category, but... that's me. |
I've just run into this issue while trying to get certain VT input modes to work in Windows Terminal, and I'm trying to work out what the actual problem is here. I get that the key down event doesn't include character data, but we've already got code in place that can generate that character data automatically (see the But lets assume the And if that really is still a concern, another approach we could take would be to save the most recent character in the Are there more factors at play here that I'm overlooking? Or does anyone have suggestions for sample keystrokes I should be testing that would be expected to fail? Because everything I've tried so far seemed to work OK (or at least no worse than the current implementation). |
This PR adds support for the `DECARM` (Auto Repeat Mode) sequence, which controls whether a keypress automatically repeats if you keep it held down for long enough. Note that this won't fully work in Windows Terminal until issue #8440 is resolved. Every time we receive a `KeyDown` event, we record the virtual key code to track that as the last key pressed. If we receive a `KeyUp` event the matches that last key code, we reset that field. Then if the Auto Repeat Mode is reset, and we receive a `KeyDown` event that matches the last key code, we simply ignore it. ## Validation Steps Performed I've manually tested the `DECARM` functionality in Vttest and confirmed that it's working as expected. Although note that in Windows Terminal this only applies to non-alphanumeric keys for now (e.g. Tab, BackSpace, arrow keys, etc.) I've also added a basic unit test that verifies that repeated key presses are suppressed when the `DECARM` mode is disabled. Closes #13919
Probably there aren't -- I think you've by this point investigated it deeper than the rest of us in recent history. We just got another dupe for it, and I am wondering if there's something we can do about it... While we're breaking input, and all. 😁 |
I've got an old branch with my initial simple proposal (relying on |
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 a loop 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 up events for both the `Shift` and the `A`, while conhost only generates both events for the `Shift` - the `A` won't generate a key up event unless you release the `Shift` before the `A`. That seems more like a conhost 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 events for 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 appear to 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
Environment
In the classic windows console, you can track alphanumeric key combinations (for example, tracking the keys w, a, s, d simultaneously). This tracking cannot be done in Windows Terminal.
Steps to reproduce
Run the following code
Press a couple of alphanumeric keys at the same time, e.g. q+w+e
Expected behavior
Key combinations are tracked (classic console behavior)
Actual behavior
Single keystrokes are tracked only (Windows Terminal behavior)
The text was updated successfully, but these errors were encountered: