Get Enter Key

This is a discussion on Get Enter Key within the C++ Programming forums, part of the General Programming Boards category; I am writing a program that is supposed to go through a loop each time someone hits the Enter key, ...

You could have two threads. One that handle the keyboard input, and one that acctually do stuff. These two threads must share the variable KayPressed.

you could also do like this, and this is how most games would work like (exept those that works like the above

Code:

void mainloop()
{
while(bGameRunning)
{
GetInput(); // <- set the Kayboard/Mouse/Joystick structs
UpdateObjects(); /* <- this function update all game
objects, these object can use the Keyboard variable and do
stuff depending on what key is pressed. EX "Walk North". */
Render();
}
}

This is an easy simplified example... Depending on your programming skills, you can expand this. I have for example an eventbased system where a keypress can trigger an event for the game object (player or UI or something like that), and a mouseclick can trigger an objects event if its pressed.

So... how you do this is up to your skills... If you asked how to get the keyboard input in the first place, then I just say www.google.com everything is there...