Can you tell me how i could get my program to recognise when the user presses any arrow key up,down,left,right?
Can you tell me how i could get my program to recognise when the user presses any arrow key up,down,left,right?
you could use the bioskey(0); function in bios.h to see the interger value of the keys
an eg program
----------
#include<iostream.h>
#include<conio.h>
#include<bios.h>
void main()
{
int key;
clrscr();
cout<<"Press any key...";
key=bioskey(0);
cout<<"\ninteger value : "<<key;
getch();
}
--------
like if you pressed enter it will give 7181 as output.
use for loop to see for all keys.
Hope this helps..
bios.h any other way?
This should work on Dev C++ -
Code:#include <iostream> #include <windows.h> using namespace std; int main() { while(1) { if(GetAsyncKeyState(VK_UP)) cout << "UP"<<endl; if(GetAsyncKeyState(VK_DOWN)) cout << "DOWN"<<endl; //etc } return 0; }
#include <iostream.h>
#include <conio.h>
//There may be others im not sure....
int main()
{
while(1)
{
char key = getch();
if (key == 27) //This is ascii code for ESC (what you use)
break;
}
return 0;
}
Tell me if i helped
Code:#if _emo #define stereo_type_i_dislike #endif
would that work in VC++?Originally posted by Sorensen
This should work on Dev C++ -
Code:#include <iostream> #include <windows.h> using namespace std; int main() { while(1) { if(GetAsyncKeyState(VK_UP)) cout << "UP"<<endl; if(GetAsyncKeyState(VK_DOWN)) cout << "DOWN"<<endl; //etc } return 0; }
"No! I must have my delicious cupcakes, my sweet cakey treasures, piping hot from their 40 watt WOMB!!!"
--Captain Murphy
just out of curiosity, why don't u try it and find out??