0

The console Read command does not recognize VK_ESCAPE. When using ReadConsoleInput, it is case insensitive. Is there something adequate to Read/Readln, which reports an abort?

AmigoJack
  • 5,234
  • 1
  • 15
  • 31
USauter
  • 295
  • 1
  • 9

1 Answers1

2
  • The docs on Read() tell you it's for characters, not keys in general. It will also not help you to i.e. recognize PgUp or Print. That's also why it is so similar to Readln(), which unsurprisingly is for text, too, not separate keys being pressed.
  • A console process does not know by default what "abort" means. Common knowledge (even unbound to Windows) is that Ctrl+C and/or Ctrl+Break terminate the process.
  • Neither a ReadConsoleInput() nor is its KEY_EVENT record case insensitive: again you get keys, not characters. Which means you have to check if .dwControlKeyState has either SHIFT_PRESSED or CAPSLOCK_ON set to translate all the keys into an appropriate character (i.e. only Shift+S makes it an uppercase S).

It's up to you to decide when to interpret keys and when treating input as text/characters. Yes: recognizing Esc while using Readln() will never work - you'd have to reinvent your own Readln(), i.e. dealing with all the input, including your favorite keys, such as Esc. This will also help you discover which keys (that you type) lead to which VK constants.

AmigoJack
  • 5,234
  • 1
  • 15
  • 31