while(!isKeypressed())
{
//... do something
}
bool isKeyPressed()
{
return true;
}
need something like keypressed
Does anyone knows waht is the func. in c++ that returns 1 or seomthing else when key is pressed. something like:
Quote:Original post by Odiee
Does anyone knows waht is the func. in c++
There is none in the Standard C++ Library. You will need to use an external library, such as the Win32 API, SDL, wxWidgets, etc.
While there's nothing cross platform in Standard C++, you could use the Win32 API to query a key's state via GetAsyncKeyState().
You could also look into conio.h and make one yourself, but as before, conio.h is not cross platform.
[Edited by - tychon on December 1, 2005 5:18:21 AM]
You could also look into conio.h and make one yourself, but as before, conio.h is not cross platform.
bool KeyPressed( int key ){ if ( kbhit() ) if ( getch() == key ) return true; return false;}
[Edited by - tychon on December 1, 2005 5:18:21 AM]
Quote:Original post by tychon
While there's nothing cross platform, you could use the Win32 API to query a key's state via GetAsyncKeyState().
You could also look into conio.h and make one yourself, but as before, conio.h is not cross platform.
bool KeyPressed( int key )
{
if ( kbhit() )
if ( getch() == key )
return true;
return false;
}
Nothing cross platform, ehh? What about SDL? Yes, it is an external library, but it's cross platfor unlike those you mentioned.
C++
Quote:Original post by Anonymous Poster
Nothing cross platform, ehh? What about SDL? Yes, it is an external library, but it's cross platfor unlike those you mentioned.
C++
I meant to imply nothing cross platform in Standard C++. Post edited to show this.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement