Skip to content

Something wrong with keyboard modifiers processing? #1694

Closed

Description

@igorkuzuro

Something wrong with keyboard modifiers processing?

We have wrong processing of keyboard input with modifiers... For example:

using System;

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			ConsoleKeyInfo cki;
			do
			{
				cki = Console.ReadKey();
				Console.Write(" --- You pressed ");
				if ((cki.Modifiers & ConsoleModifiers.Alt) != 0)
				{
					Console.Write("ALT+");
				}
				if ((cki.Modifiers & ConsoleModifiers.Shift) != 0)
				{
					Console.Write("SHIFT+");
				}
				if ((cki.Modifiers & ConsoleModifiers.Control) != 0)
				{
					Console.Write("CTL+");
				}
				Console.WriteLine(cki.Key.ToString());
			}
			while (cki.Key != ConsoleKey.Escape);
		}
	}
}

Same keys sequence is pressed... 1 2 ... 0 RCtrl+1 RCtrl+2 RCtrl+3... RCtrl+0
LCtrl+1 LCtrl+2 LCtrl+3 LCtrl+4

We have some, but also wrong result only for Ctrl+2... Shift modifier added.

image

Same behaviour also with more complicated software - "Far Manager" for example (in this situation problem not with simple Console.ReadKey but with keyboard events processing. In this example we don't see any reactions of software on pressing Ctrl like we can see in old console. So problems also with keyboard modifiers).

Activity

  1. ghost added
    Needs-TriageIt's a new issue that the core contributor team needs to triage at the next triage meeting
    on Jun 28, 2019
  2. ghost added
    Needs-Tag-FixDoesn't match tag requirements
    on Jun 28, 2019
  3. DarthJahus commented on Jul 1, 2019

    @DarthJahus

    I've got an issue with this. When I press ALTGR+à to write @ on French layout keyboard, it writes à. This makes it unusable with a French keyboard.

    Also, looks like a duplicate of #521

  4. added
    Area-InputRelated to input processing (key presses, mouse, etc.)
    Area-VTVirtual Terminal sequence support
    Issue-BugIt either shouldn't be doing this or needs an investigation.
    and removed
    Needs-TriageIt's a new issue that the core contributor team needs to triage at the next triage meeting
    on Jul 1, 2019
  5. ghost removed
    Needs-Tag-FixDoesn't match tag requirements
    on Jul 1, 2019
  6. DHowett-MSFT commented on Jul 2, 2019

    @DHowett-MSFT
    Contributor

    Jahus (@DarthJahus) that is the unrelated issue #521, which is fixed and will be released eventually.

  7. j4james commented on Nov 12, 2019

    @j4james
    Collaborator

    There are a combination of issues here. First off, we don't correctly support the VT sequences for the number characters when combined with Ctrl. Only Ctrl+2 works, and even then it's only on certain keyboards. This is discussed in issue #3507.

    The bigger problem is that the standard VT sequences for transmitting keypresses are limited in what they can represent. So even if we were handling these keys perfectly, there's no difference between the left and right Ctrl keys, and something like Ctrl+2 should show up as the same key as Ctrl+SPACE and Ctrl+@ (which on a US keyboard is Ctrl+Shift+2). Potential solutions for this are discussed in issue #879.

  8. ghost added
    In-PRThis issue has a related PR
    on Jun 2, 2020
  9. ghost closed this as completedin #6309on Jun 8, 2020
  10. ghost added a commit that references this issue on Jun 8, 2020
    f327618
  11. ghost removed
    In-PRThis issue has a related PR
    on Jun 8, 2020
  12. ghost added
    Resolution-Fix-CommittedFix is checked in, but it might be 3-4 weeks until a release.
    on Jun 8, 2020
  13. added a commit that references this issue on Sep 5, 2020
    0b3beb7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Area-InputRelated to input processing (key presses, mouse, etc.)Area-VTVirtual Terminal sequence supportIssue-BugIt either shouldn't be doing this or needs an investigation.Product-TerminalThe new Windows Terminal.Resolution-Fix-CommittedFix is checked in, but it might be 3-4 weeks until a release.

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions