Something wrong with keyboard modifiers processing? #2352

Closed
opened 2026-01-30 22:53:05 +00:00 by claunia · 4 comments
Owner

Originally created by @igorkuzuro on GitHub (Jun 28, 2019).

Originally assigned to: @zadjii-msft on GitHub.

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).

Originally created by @igorkuzuro on GitHub (Jun 28, 2019). Originally assigned to: @zadjii-msft on GitHub. Something wrong with keyboard modifiers processing? We have wrong processing of keyboard input with modifiers... For example: ```c# 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... <kbd>1</kbd> <kbd>2</kbd> ... <kbd>0</kbd> <kbd>RCtrl</kbd>+<kbd>1</kbd> <kbd>RCtrl</kbd>+<kbd>2</kbd> <kbd>RCtrl</kbd>+<kbd>3</kbd>... <kbd>RCtrl</kbd>+<kbd>0</kbd> <kbd>LCtrl</kbd>+<kbd>1</kbd> <kbd>LCtrl</kbd>+<kbd>2</kbd> <kbd>LCtrl</kbd>+<kbd>3</kbd> <kbd>LCtrl</kbd>+<kbd>4</kbd> We have some, but also wrong result only for <kbd>Ctrl</kbd>+<kbd>2</kbd>... Shift modifier added. ![image](https://user-images.githubusercontent.com/1778999/60325129-392af380-998f-11e9-962b-354f7c755531.png) 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 <kbd>Ctrl</kbd> like we can see in old console. So problems also with keyboard modifiers).
Author
Owner

@DarthJahus commented on GitHub (Jul 1, 2019):

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

@DarthJahus commented on GitHub (Jul 1, 2019): 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
Author
Owner

@DHowett-MSFT commented on GitHub (Jul 2, 2019):

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

@DHowett-MSFT commented on GitHub (Jul 2, 2019): @DarthJahus that is the unrelated issue #521, which is fixed and will be released eventually.
Author
Owner

@j4james commented on GitHub (Nov 12, 2019):

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.

@j4james commented on GitHub (Nov 12, 2019): 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.
Author
Owner

@ghost commented on GitHub (Jun 18, 2020):

:tada:This issue was addressed in #6309, which has now been successfully released as Windows Terminal Preview v1.1.1671.0.🎉

Handy links:

@ghost commented on GitHub (Jun 18, 2020): :tada:This issue was addressed in #6309, which has now been successfully released as `Windows Terminal Preview v1.1.1671.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.1.1671.0) * [Store Download](https://www.microsoft.com/store/apps/9n0dx20hk701?cid=storebadge&ocid=badge)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#2352