Check out example codes for "how to use wasd c++". It will help you in understanding the concepts better.

Code Example 1

#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
    char ch=0;
    cout << "Press Q to quit\n";
    do
    {
        ch = getch();

        switch(ch)
        {
            case 'W':
            case 'w':
                cout << "W was pressed \n";
                break;
            case 'A':
            case 'a':
                cout << "A was pressed \n";
                break;
            case 's':
            case 'S':
                cout << "S was pressed \n";
                break;
            case 'D':
            case 'd':
                cout << "D was pressed \n";
                break;

        }

    }while (ch != 'Q' && ch!='q');
}

Learn ReactJs, React Native from akashmittal.com