// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
#include <conio.h>

#include <iostream>

using namespace std;

int main()
{
   cout << "Press keys (ESC to exit)" << endl;
   while(true)
   {
      int c = getch();
      if(c == 0x1B)
      {
         cout << "ESC read" << endl;
         break;
      }
      else if(c == 224)
      {
         c = getch();
         switch(c)
         {
            case 75:
                cout << "left arrow read" << endl;
                break;
            case 77:
                cout << "rigth arrow read" << endl;
                break;
            case 72:
                cout << "up arrow read" << endl;
                break;
            case 80:
                cout << "down arrow read" << endl;
                break;
         }
      }
      else
      {
         cout << (char)c << " read" << endl;
      }
   }
   return 0;
}
