Closed
Description
Description
See the following code:
using System;
using System.Threading;
var a = Console.TreatControlCAsInput;
Console.TreatControlCAsInput = true;
var key = Console.ReadKey(true);
Console.WriteLine("KEY: " + key.Key);
Console.WriteLine("MODS: " + key.Modifiers);
Console.TreatControlCAsInput = a;
Now run dotnet run
and type Ctrl+C
You would expect to see:
KEY: C
MODS: Control
because TreatControlCAsInput
is true
, but you don't - it interupts the process.
Now set this instead in the example above
Console.TreatControlCAsInput = false;
Now run dotnet run
and type Ctrl+C
... you get:
KEY: C
MODS: Control
when I would expect the process to be interupted.
Configuration
- Which version of .NET is the code running on? .NET 5 RC1
- What OS and version, and what distro if applicable? macOS Catalina
- What is the architecture (x64, x86, ARM, ARM64)? x64
- Do you know whether it is specific to that configuration? No. It could be others. Not sure.
Regression?
Yes. This worked in preview 8. Setting:
Console.TreatControlCAsInput = true;
would allow ReadKey
to return a KeyInfo
and
Console.TreatControlCAsInput = false;
would cause Ctrl+C to interupt the process.