Re: Win32 (GetAsyncKeyState)
- Posted by Molasses <molasses at ALPHALINK.COM.AU> May 20, 1999
- 557 views
Sorry that's not it. GetAsyncKeyState takes a key value and returns true or false. is_pressed = GetAsyncKeyState(VK_ESCAPE) The problem being, if I'm only checking for the arrow keys and escape and the user hits say enter then the arrow keys and escape will stop responding. I suppose after checking for the keys I need I could do this to clear any other keys: for i = 0 to 255 do null = GetAsyncKeyState(i) end for But there's got to be a better way than that. -molasses ----- Original Message ----- From: Adam Weeden <theskaman at MINDSPRING.COM> To: <EUPHORIA at LISTSERV.MUOHIO.EDU> Sent: Wednesday, 19 May 1999 3:13 pm Subject: Re: Win32 (GetAsyncKeyState) > It might be this. In C (and its successor) whenever you are testing a > variable against many values you use a switch statement like this: > > // Sorry abou the C code, necessary to show my point. > // Assume we have already set value of key to what ASyncKeyState > // returns. > > switch(key) > { > case VALUE1: > { > // Do whatever you need to do for VALUE1 > } break; > case VALUE2: > { > // Do whatever you need to do for VALUE2 > } break; > default: > { > // If key doesnt match any of the above values do this > } break; > } > > In Euphoria this could be wriiten as > If key = VALUE1 then -- Keep in mind VALUE1 in my example is a > -- constant so this is legal. > > -- Do whatever you need to do for VALUE1 > elsif key = VALUE2 then > -- Do whatever you need to do for VALUE2 > else > -- If key doesnt match any of the above values do this > end if > > My point is that maybe you need some sort of function that would parse a > return value of GetAsyncKeyState that you do not need. > Just a thought.