Skip to content
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

"CTRL+M" is captured as "Enter" in console app on Linux #73379

Closed
MrM40 opened this issue Aug 4, 2022 · 7 comments
Closed

"CTRL+M" is captured as "Enter" in console app on Linux #73379

MrM40 opened this issue Aug 4, 2022 · 7 comments

Comments

@MrM40
Copy link

MrM40 commented Aug 4, 2022

Description

In .Net 6 vb.net Console.ReadKey() read "CTRL+M" as "Enter"
image

Any other CTRL+ combinations seems to work fine e.g. "CTRL+L":
image

I worked fine in .net core 2.2

Tried on OpenSUSE 15.3 and Debian 11 Linux boxes (also directly on the VGA/keyb console).
And tested nn these terminals: Kitty and Windows Terminal.

.net runtime installation on the Linux box:
image

Reproduction Steps

Debug Console.ReadKey() and see what .net interpret the key keystroke CTRL+M

Expected behavior

ConsoleKeyInfo.Modifiers should be Control
and
ConsoleKeyInfo.Key should be M

Actual behavior

Read as Enter

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Aug 4, 2022
@ghost
Copy link

ghost commented Aug 4, 2022

Tagging subscribers to this area: @dotnet/area-system-console
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

In .Net 6 vb.net Console.ReadKey() read "CTRL+M" as "Enter"
image

Any other CTRL+ combinations seems to work fine e.g. "CTRL+L":
image

I worked fine in .net core 2.2

Tried on OpenSUSE 15.3 and Debian 11 Linux boxes (also directly on the VGA/keyb console).
And tested nn these terminals: Kitty and Windows Terminal.

.net runtime installation on the Linux box:
image

Reproduction Steps

Debug Console.ReadKey() and see what .net interpret the key keystroke CTRL+M

Expected behavior

ConsoleKeyInfo.Modifiers should be Control
and
ConsoleKeyInfo.Key should be M

Actual behavior

Read as Enter

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Author: MrM40
Assignees: -
Labels:

area-System.Console

Milestone: -

@danmoseley
Copy link
Member

Can you try with the latest daily build of .NET 7?

@MrM40
Copy link
Author

MrM40 commented Aug 4, 2022

I will tomorrow....thanks for the suggestion.

@MrM40
Copy link
Author

MrM40 commented Aug 5, 2022

Ohhh....I see I need to reinstall (or at least update) my Visual Studio 2022 for 7.0 support, which I don't dare right now. It's my production PC :-/
If you already have a 7.0 environment up an running, can you make a quick test-project?
Or perhaps just take a quick look in the 6.0 code.....I wouldn't be suppressed if it was just the switch-value for CTRL-M which wasn't updated (I have no clue where to look myself)

@danmoseley
Copy link
Member

danmoseley commented Aug 5, 2022

You do not need to modify VS in any way. Installations of .NET are side by side. See

https://github.com/dotnet/runtime/blob/main/docs/project/dogfooding.md

You will just change the TargetFramework of your test project, by editing it directly.

@adamsitnik adamsitnik removed the untriaged New issue has not been triaged by the area owner label Aug 5, 2022
@adamsitnik adamsitnik added this to the 7.0.0 milestone Aug 5, 2022
@adamsitnik
Copy link
Member

Hi @MrM40

Every Unix Terminal maps keys pressed by the user to their byte representation that .NET reads via read() sys-call.

The best utility for finding out the mappings is using showkey -a Linux command line tool.

In the following picture I've pressed Enter, Ctrl+J and Ctrl+M:

image

As you can see, Ctrl+M is just mapped to exactly same byte as Enter (0x0d) by the Terminal. This is a Unix convention; .NET has no control over that. We can't map Ctrl+M to Ctrl+M because it would mean that we would need to map Enter to Ctrl+M as well.

We have rewritten Console.ReadKey for .NET 7 and in #72193 I've listed all limitations:

  • Ctrl+M is mapped to Enter with carriage return character (\r)
  • Ctrl+J is mapped to Ctrl+Enter with new line character (\n)
  • Ctrl+I is mapped to Tab
  • Clr+H is mapped to Ctrl+Backspace

This is by design.

@adamsitnik adamsitnik closed this as not planned Won't fix, can't repro, duplicate, stale Aug 5, 2022
@MrM40
Copy link
Author

MrM40 commented Aug 5, 2022

@adamsitnik
Confirmed!
I guess it wasn't work in .NET Core 2.2 after all :-/
Thanks for sharing your wisdom and sorry for the "noise".

@ghost ghost locked as resolved and limited conversation to collaborators Sep 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants