C++ gurus and learners, we program ourselves :P all work is CC licensed

Tuesday, January 7

ARROW KEYS IN C++

00:09 By

WANT TO INCLUDE ARROW KEYS IN YOUR C++ PROGRAM !!! JUST copy this code in your compiler, execute and press arrow keys. .. this code is only for hint on how to use arrow keys oin your c++ program..... REMEMBER ASCII codes of arrow keys 1. Up key = 72 2. Down key = 80 3. Left key = 75 4. Right key = 77

//arrow keys in c++
#include
#include 
using namespace std;
 
void main()
{
 char a;
  
 while(a<100)//infinite loop
 
 {
 
 a = getch();
 if (a == 80) 
  cout<<"DOWN\n";
 
 else
  if (a == 72) 
   cout<<"UP\n";
 
 else
  if (a == 77) 
   cout<<"RIGHT\n";
 
 else
  if (a == 75) 
  cout<<"LEFT\n";
 }
}
 

 

1 comments :