Search
 
SCRIPT & CODE EXAMPLE
 

CPP

C++ Detect when user presses arrow key

#include <conio.h>
#include <iostream>
using namespace std;

#define KEY_UP 72
#define KEY_DOWN 80
#define KEY_LEFT 75
#define KEY_RIGHT 77

int main()
{
    int c = 0;
    while(1)
    {
        c = getch();

        switch(c) {
        case KEY_UP:
            cout << endl << "Up" << endl;
            break;
        case KEY_DOWN:
            cout << endl << "Down" << endl;
            break;
        case KEY_LEFT:
            cout << endl << "Left" << endl;
            break;
        case KEY_RIGHT:
            cout << endl << "Right" << endl;
            break;
        default:
            cout << endl << "null" << endl;
            break;
        }
    }

    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: the number of ones int bitset 
Cpp :: pointer in cpp details 
Cpp :: convert string to double arduino 
Cpp :: c++ to mips converter online 
Cpp :: how to seek to the start of afile in c++ 
Cpp :: C++ using a member function of a class to pass parameters to a thread 
Cpp :: PascalName seperate strings 
Cpp :: check .h files syntax c++ 
Cpp :: coin change top-down 
Cpp :: why wont a function stop C++ 
Cpp :: txt to pdf CPP 
Cpp :: Link List Insertion a node 
Cpp :: ue4 c++ enum variable declaration 
Cpp :: Increase IQ codechef solution in c++ 
Cpp :: c++ click event 
Cpp :: c++ vector add scalar 
Cpp :: input many numbers to int c++ 
Cpp :: sort using comparator anonymous function c++ 
Cpp :: c++ define function in header 
Cpp :: c++ watch a variable 
Cpp :: convert c program to c ++ online 
Cpp :: [3,2,4,-1,-4] 
Cpp :: how to replace a element in a vector c++ using index 
Cpp :: ros pointcloud2 read_points c++ 
Cpp :: c++ program 
Cpp :: how to convert malloc function to cpp 
Cpp :: codeform 
Cpp :: +++++++++ 
Cpp :: 12 to december in c++ code 
Cpp :: Required Length 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =