|
Post by Nicky Peter Hollyoake on Mar 11, 2009 7:32:15 GMT -5
Which way would people suggest on going with when getting the keystate in C++? if (GetKeyState (VK_SPACE)) { // Code } or if (kbhit()) { SomeVar = getch(); } (I think thats how it goes, ain't tested ;p). I see that programmers here are gonna choose the first one because its simple, but I don't want the simplest I wanna know the difference and have they got there own advantages? Actually now that I read this post I guess the second one is best for reading keys, and the first is best for reading stuff like ctrl, space, return key, etc. Still want a second opinion though. - Nicky
|
|
|
Post by matthew on Mar 11, 2009 8:47:02 GMT -5
I personally wouldn't use getch as it's not used a lot today, GetKeyState is better but it's Windows specific so if you eventually decide to port your program do another Operating System you'll need to find a new way to handle key presses. You might want to take a look at SDL as it offers a multi-platform way to deal with the keyboard.
|
|
|
Post by Nicky Peter Hollyoake on Mar 11, 2009 15:27:45 GMT -5
I personally wouldn't use getch as it's not used a lot today, GetKeyState is better but it's Windows specific so if you eventually decide to port your program do another Operating System you'll need to find a new way to handle key presses. You might want to take a look at SDL as it offers a multi-platform way to deal with the keyboard. I'm ok with windows programming, windows will always be used anyways. Thanks for the answer, - Nicky
|
|