Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #define W 119
- #define A 97
- #define S 115
- #define D = 100
- int main()
- {
- int key = getch();
- // Uncomment this if you would like to know keys
- // Simply uncomment this, comment the switch, run the program, and just press keys to get an integer value
- // Make a #define statement, give it a name of the key, and give it an integer value of the key.
- // e.g. W = 119
- /*
- std::cout << key << "\n\n";
- */
- switch(key)
- {
- case W:
- std::cout << "W was pressed\n\n";
- break;
- case A:
- std::cout << "A was pressed\n\n";
- break;
- case S:
- std::cout << "S was pressed\n\n";
- break;
- case D:
- std::cout << "D was pressed\n\n";
- break;
- }
- std::cin.get(); // Used to see the output window. Just in case
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement