title: How to detect key arrow key press in C++ in OSX?
body: <p>I am trying to make a terminal snake game in C++ in macOSX. How do I detect which arrow key is pressed? </p>
  
  <p>I tried to do this with getch() of ncurses.h but this is not solving the problem. No output is being detected. </p>
  
  <pre><code>#define KEY_UP    72
  #define KEY_LEFT  75
  #define KEY_RIGHT 77
  #define KEY_DOWN  80
  
  void Input()
  {
      int c = 0;
      switch ((c = getch()))
      {
      case KEY_UP:
          cout &lt;&lt; endl&lt;&lt; "Up" &lt;&lt; endl; //key up
          break;
      case KEY_DOWN:
          cout &lt;&lt; endl&lt;&lt; "Down" &lt;&lt; endl; // key down
          break;
      case KEY_LEFT:
          cout &lt;&lt; endl&lt;&lt; "Left" &lt;&lt; endl; // key left
          break;
      case KEY_RIGHT:
          cout &lt;&lt; endl&lt;&lt; "Right" &lt;&lt; endl; // key right
          break;
      default:
          break;
      }
  }
  </code></pre>