getch() reads two characters from one arrow key press

后端 未结 1 1940
南旧
南旧 2021-01-29 12:20

Today i was testing how key pressing might work in C++ and made simple loop for it,and found that getch() duplicate itself for some reason or idk what is going on honestly,just

相关标签:
1条回答
  • 2021-01-29 13:02

    From MS documentation

    Remarks

    The _getch and_getwch functions read a single character from the console without echoing the character. None of these functions can be used to read CTRL+C. When reading a function key or an arrow key, each function must be called twice; the first call returns 0 or 0xE0, and the second call returns the actual key code.

    When you press arrow keys, the input is 2 chars

    0 讨论(0)
提交回复
热议问题