title: Scrolling menu in the console
body: <p>There is the menu in the console navigating by arrows UP-DOWN. Problem: when I select "Enter number" and the result disappears, I can't select another menu item. How to fix it?</p>
  
  <p>Here is my C++ code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;windows.h&gt;
  
  using namespace std;
  
  int main()
  {
      string Menu[2] = {"Enter number", "Exit"};
      int pointer = 0;
  
      while(true)
      {
          system("cls");
  
          SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 15);
          cout &lt;&lt; "Main Menu\n\n";
  
          for (int i = 0; i &lt; 2; ++i)
          {
              if (i == pointer)
              {
                  SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 11);
                  cout &lt;&lt; Menu[i] &lt;&lt; endl;
              }
              else
              {
                  SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 15);
                  cout &lt;&lt; Menu[i] &lt;&lt; endl;
              }
          }
  
          while(true)
          {
              if (GetAsyncKeyState(VK_UP) != 0)
              {
                  pointer -= 1;
                  if (pointer == -1)
                  {
                      pointer = 1;
                  }
                  break;
              }
              else if (GetAsyncKeyState(VK_DOWN) != 0)
              {
                  pointer += 1;
                  if (pointer == 2)
                  {
                      pointer = 0;
                  }
                  break;
              }
              else if (GetAsyncKeyState(VK_RETURN) != 0)
              {
                  switch (pointer)
                  {
                      case 0:
                      {
                          int number;
                          cout &lt;&lt; "\nEnter number --&gt; ";
                          cin &gt;&gt; number;
                          cout &lt;&lt; "\nThe number is ";
                          cout &lt;&lt; number;
                          Sleep(1000);
                      } break;
                      case 1:
                      {
                          return 0;
                      } break;
                  }
                  break;
              }
          }
  
          Sleep(150);
      }
  
      return 0;
  }
  </code></pre>
  
  <p>Maybe, it will be better to use Qt::Key instead of GetAsyncKeyState?</p>