The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Neil on July 12, 2010, 10:19:57 AM

Title: Check keypress
Post by: Neil on July 12, 2010, 10:19:57 AM
Is there a function that checks if any key has been pressed, & if not doesn't wait but carries on with code something like GetAsyncKeyState but without checking for a particular key?
Title: Re: Check keypress
Post by: dedndave on July 12, 2010, 11:30:43 AM
MS VC runtime library has "crt__kbhit"
if you look at the masm32 wait_key.asm file, you'll see it in use
Title: Re: Check keypress
Post by: Neil on July 12, 2010, 12:09:43 PM
Thanks Dave, that looks promising  :U. It must do something like checking the 'Head' & 'Tail' pointers in the keyboard buffer as you could in DOS
Title: Re: Check keypress
Post by: Neil on July 12, 2010, 12:19:55 PM
I've put a bit of code together & it does exactly what I want, brilliant  :bg
Title: Re: Check keypress
Post by: dedndave on July 12, 2010, 01:13:49 PM
you can get away from the crt if you want by using PeekConsoleInput and ReadConsoleInput
but it is a bit of a bag of worms   :P
Title: Re: Check keypress
Post by: Neil on July 12, 2010, 01:55:58 PM
Yes, I'll stick with what I know works.