How to make a program not wait for input

closed account (42hU7k9E)
My program uses getch(); to get input, but the program stops until the user inputs something. I want the program to do other things even if the user does not input anythng. I tried GetAsyncKeyState, it worked nice, but if you pressed a key once, it was like you pressed it twice.
Last edited on
closed account (S6k9GNh0)
Well, you can create another thread I think (I've never made a thread). Other than that, you just need to do everything before you get input.
Last edited on
you could do something like this with GetAsyncKeyState to make it return true only once:
1
2
3
4
5
6
7
8
bool keydown=0;
while(...){
    //do stuf
    if(!keydown && GetAsyncKeyState(...)){
        //do other stuf
    }
    keydown=GetAsyncKeyState(...);
}

Last edited on
closed account (42hU7k9E)
Which library do I need to include so the !keydown will work?
closed account (42hU7k9E)
Does any1 have an idea?
'keydown' is just a variable, you need windows.h to have GetAsyncKeyState
Topic archived. No new replies allowed.