Skip to main content
gamedev.net
🔒 Locked

wait state until keypressed

Started by CrystalClear Apr 2, 2004 at 6:57 AM 0 replies 650+ views
Original Post
CrystalClear
CrystalClear
in int WINAPI WinMain() how would you keep in a loop until return key is pressed?? want to do something like int x x = 0 while( x==0 ) { if( keypressed = return ) { x=1 } }
paulecoyote
paulecoyote
Errr... don''t do that, you''ll lock up everything spinning like that. You can poll and sleep, or use key events. Depending on what you are programming (and by winmain I guess not a console app) depends on how you may want to get your keypress. You will want to sink GDI keypress events, or use the DirectX Input API.

But never spin like that in the main execution thread. It''s bad.
Anything posted is personal opinion which does not in anyway reflect or represent my employer. Any code and opinion is expressed “as is” and used at your own risk – it does not constitute a legal relationship of any kind.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.