-
Notifications
You must be signed in to change notification settings - Fork 703
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
Fixes #2008 - Shift+key denied by text field as "control character" on remote systems #2032
Conversation
…onsoleKey.Packet. Affects only WindowsDriver
@heinrich-ulbricht please are you able to test my PR to see if this has any effect on your Shift+char issue with I have gone to the point where the keystrokes first appear in Since I don't have a machine that sends these PACKET entries I can't test it myself. But I have written a couple of unit tests and if successful I can write some more to make sure nothing goes wrong when trying to remap wierd characters e.g. 'newline' or 'escape' etc. I've left it as draft for now since I want to see that
For the remapping I followed this thread on StackOverflow. But adjusted it to correctly handle lower case too. Test is written to use |
Thank you, will do this weekend! |
@tznind Looks promising. It works for A, B etc. But not for : and other non-alphabet characters. For those the |
May be for them is not necessary to be mapped and come with the correct key code? So only try parse from A to Z? |
Had a look at
But the same is true for 'A'. |
The |
Some tests: Ctrl
Ctrl+Shift
Ctrl+Shift+A
Shift+7 == '/'
According to both Shift+a == 'A'
Shift+ß == '?'
A German speciality: ß
A classic: ü
u
Return/Enter
Space
Right arrow
Home
Ctrl+Pos1
Ctrl+q
|
That's great @heinrich-ulbricht thanks for testing. I suspected that I suspect for the foreign language keys there might still be issues. But since you can now type the US letters, this approach seems sensible to start with. Your comment is very helpful where it shows what is and isn't working, I can add those to the unit test I created. |
@tznind I have URL input fields so as long as one can type URLs it's fine for me 🤪 |
@heinrich-ulbricht please can you see how it is behaving now. I have mapped every key on my US layout keyboard and added the novel characters that appear in UK keyboard (since I also have one of those to test with). I'm not sure what to do with characters that appear in different keys on different keyboard layouts (e.g. I didn't seem to see all the It seems that some of the code I am writting is similar to |
@tznind It works better now, I can input URLs ^^ Pressed a few more keys, single and double quotes are missing:
Somehow this approach doesn't feel right, though. I read that the packet key type was introduced to not have to deal with different keyboard layouts when sending remote key presses around. To "just pass the actual key through" without going through multiple transformations. It would be nice if we could do that. But this again somehow feels like it might require a bigger architectural change. Edit: Thought about that. If the final console output IS dependent on those enums then there is no choice. As an immediate workaround it definitely solves the (my) problem. |
I agree this definetly feels a bit sketchy. I'm very much open to talking more about this though! Terminal.Gui keyboard eventsAll the The Key Enum
This means that any Because Terminal.Gui/Terminal.Gui/Core/Event.cs Lines 139 to 147 in 558b2b7
The Terminal.Gui/Terminal.Gui/Core/Event.cs Lines 487 to 492 in 558b2b7
ConsoleKey
SummarySo the goal here is to correctly convert
I think my going via |
Ok @heinrich-ulbricht please can you try updating now! I have reworked the code to map to I think your keyboard will not use I don't know if it even uses Packet for Escape / Tab and Backspace but I've put those cases in anyway in Thanks for helping test this, it feels like we are nearly there. |
@tznind Well. This just works :D I can type anything in combination with Shift now. No exceptions. Here are some key events taken from Home
End
Right arrow
ESC
Shift
Shift + a pressed
Shift + Tab pressed
Return
Ctrl + Home pressed
Shift + Home pressed
Shift + End pressed
Ctrl + a pressed
By the way - is Ctrl+A (to select all text) supposed to work in input fields? Because it doesn't. Just something I noticed a while back, not sure if this is connected to our current issue. Just want to mention it just in case. Shift+Home and Shift+End do work. Thanks for diving into this. This solution feels a lot better. |
On |
@BDisp You are fast. Just this moment I pressed the right mouse key and the context menu told me this :) Strange combo, my Windows background strongly expects Ctrl+A ^^ |
|
So it looks like the packet key is not used in any of these cases (below) for you. So the following code I have in this PR will probably never be hit so could be removed in your case. But I don't know if other software or environments might use PACKET for any of these. @tig let me know if you want me to remove this code or leave it in (or anyone else who has a view!). case '\t':
result = original.Modifiers == ConsoleModifiers.Shift ? Key.BackTab : Key.Tab;
return true;
case '\u001b':
result = Key.Esc;
return true;
case '\b':
result = Key.Backspace;
return true;
case '\n':
case '\r':
result = Key.Enter;
return true; @heinrich-ulbricht one last thing I thought I'd mention incase you hadn't seen - You can change the keybinding for SelectAll with: TextField tv = new TextField ();
tv.AddKeyBinding (Key.A | Key.CtrlMask, Command.SelectAll); |
Nuke it. ;-) |
…nario TreeViewFileSystem
…when not MultiSelect
Pressing only shift with a lowercase or a digit the uppercase or symbol must be the character to display.
@tznind I submitted the PR tznind#128 to your branch. I already merged the develop branch because of the resulting conflicts. All drivers, except the |
This is awesome work thanks! I have merged the PR and will get to testing it / looking in depth asap. Do you consider this now as good to go? shall I mark it no longer Draft? |
Thanks.
I forgot to delete the |
Done tznind#134. Thanks for your waiting. |
Removed unnecessary method.
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.
Lovely!
Fixes #2008 - When using some remoting technologies some keyboard input is supplied as
ConsoleKey.Packet
.Pull Request checklist:
CTRL-K-D
to automatically reformat your files before committing.dotnet test
before commit///
style comments)