Runtime: Console ReadKey echo escapes

Created on 1 Apr 2018  路  6Comments  路  Source: dotnet/runtime

@devel0 commented on Sat Mar 31 2018

Using Console.ReadKey(true) should not echo control keys but in linux terminal I got ^[OC echos.

version

  • dotnet version : 2.1.101
  • os : ubuntu 17.10

repro

Console.ReadKey(true);
  • press "right arrow" key

expected

  • no echoes

current behavior

  • echoed ^[OC to the console
area-System.Console bug

All 6 comments

If it helps on my VM Ubuntu 16.04 "no echoes" on "right arrow" .

@MarcoRossignoli I suppose you tried Console.ReadKey() instead of Console.ReadKey(true) that would intercept key press; if you try to press "a" within Console.ReadKey() char you'll see echo of "a" that not supposed to be instead within ReadKey(true) in my case; I tried in Windows platform and ReadKey(true) doesn't echo chars "a" neither right arrow key, as expected but in Linux currently generate different beahvior echoing control keys.

@joshfree I don't understand exactly how the dotnet/runtime#24456 fixed this issue, as a workaround I used to call a utility setecho disable and enable at start and end of my console program to handle the expected behavior.

@devel0 actually i tried both, i did it throught a test and press "a" with and without true parameter behave as expected to me on 16.04(i see "aFinish..." and "Finish..." message at the end of test). Maybe use test is not correct to repro.

@MarcoRossignoli ok but you able to avoid echo of "a" and right arrow ^[OC at the same time with the same program ? If I not wrong following behavior happens:

  • ReadKey() : echo "a" but not echo arrow keys
  • Readkey(true) : don't echo "a" but echo arrow keys
    In my app I used ReadKey(true) to avoid echoing of command characters and I expecting arrow keys also gets muted while the latter not happens.

@devel0 i get your point, i didn't do test in your way, i only tested "right arrow" and close program. However i'll follow discussion on other thread.

Was this page helpful?
0 / 5 - 0 ratings