-
Notifications
You must be signed in to change notification settings - Fork 814
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
Look at Windows key handling #872
Comments
Yes, please! I believe this issue is prohibiting using anything with shift in windows, where, for example, ctrl+o works fine, shift+ctrl+o creates as you say ctrl-at sequences instead. With Windows Terminal also allocating a lot of shortcuts for itself it would be nice to expand the possible list of keys used, considering windows terminal is almost a prerequisite for performance. Every line after the ctrl+@ was really a shift+ctrl+o: (its the same in "cmd.exe" as windows terminal)
|
Oh, I noticed another thing as well, which is maybe even worse: pressing a ctrl+alt-key combo delays / blocks combos that do work, until some class of event happens. For example the lone binding
will be delayed after pressing ctrl+alt+r. This is also easily observable in "textual keys": initially, pressing ctrl+o gets immediate responses. Pressing ctrl+alt+r once, and then ctrl+o shows nothing happening.. until for example the mouse is hovered over the console. |
Dragging this into "in progress" and using this as a place to log some other issues with keys and Windows. See also the problem with the default binding for the command palette on Windows and also #3178. |
Just as a note - TextArea uses shift for a few of its bindings (shift+arrow keys, ctrl+shift+arrow keys), and they seemed to work fine when testing on Windows. |
"Native" Windows, or under Parallels? I was able to recreate the shift issue yesterday with the latest Textual. |
Just tested under "native" Windows and I'm seeing the exact same effects as I do when on my Mac under Parallels. |
After experimenting while printing out the low-level values coming in via Pressing Shift on its ownWhen Shift is depressed, nothing happens. However, when it is released, two events occur:
followed immediately by:
Pressing Shift as a modifier keyIf Shift is pressed to modify another key, there seems to be a key-down event for it, plus a down and up event for the modified version of the other key. For example, if you press Shift and 1, the following events occur:
|
Following on from this, in the heart of the Win32 driver is this bit of code: if (
key_event.dwControlKeyState
and key_event.wVirtualKeyCode == 0
):
continue If I'm reading this correctly this looks to be the start of an approach to filtering some keys out, but it doesn't go all the way. It may be that more filtering is needed here. However, this will need to be done in a way that we can be 100% confident that we're not affecting the collection of sequences for valid keys. |
If the above bit of code is extended with this: or (key == "\x00" and key_event.wVirtualKeyCode != 50) this appears to solve the problem1. That is, it appears to filter out all of the spurious NUL characters, while allowing for Ctrl+space to make it through. I'm not including this here as the solution just yet, but I am including it here as a solution (or at the very least possibly acceptable workaround). This also does raise the side-issue of why Footnotes |
Moving this back to "in progress", as the scope for this has wandered a wee bit, and also there's some variation in how Windows behaves, it seems, that means any fix here can land differently depending on the environment that Windows is in. So: I think a reset of this issue, and the associated PR, is in order. Filtering out the spurious NULs is easy enough; the question is how to we do that without filtering out a "genuine" NUL (which is often Ctrl+Space); and do we even want to care about that? There's a cost/benefit decision to make here. |
Bumping this over to "Blocked" for now; but something to keep in mind when we review #3411. |
@davep is this covered by the work you are doing on keys? |
Not really; as this one is more about how the Windows driver can cope with the spurious NULs -- unrelated to unknown escape sequences and possibly-incorrect key names. |
This just bit me for the second time. I also just noticed (for the first time) that naked Windows 11, Windows Terminal, Powershell Textual DiagnosticsVersions
Python
Operating System
Terminal
Rich Console options
|
Holding down shift creates ctrl-at keys.
The text was updated successfully, but these errors were encountered: