   keyboarding
  hello,what''s the best way to handle keys when programming a game?so far i always did it this way in the main message loop:( saw it at nehe )if(keys[''C''] && !c_pressed) { c_pressed=true; //...do something here}if(!keys[''C'']) { c_pressed=false;}but this is getting kinda annoying cause i need one extra variable for each key and this is only processed once every frame. so if the framerate is very low, chances are good the keypressing isnt realised at all.also, i dont know if this is the usual way to do it at all.how do you do it?thanks! 
  I usually like to do a switch-case block when checking keystrokes. It''s much cleaner and takes less to code.   R.I.P. Mark OsbackSolo Pa Mi GenteVG-Force;  ok, but where do you do it?and how do you check if a key is held? ;  I have an input class that has many methods, 2 of which are GetInputState() and GetInputEvents(). State retrieves the state of keys at that time, events retrieves what has changed since the last time I called the function. So in a main game-loop you can do state(), but for menus and such you can use events(). I do this by keeping a seperate copy of the keyboard state as a static variable in events() and comparing it to the actual kb state, then returning the result. ;quote:Original post by ehmdjii  but this is getting kinda annoying cause i need one extra variable for each key and this is only processed once every frame. so if the framerate is very low, chances are good the keypressing isnt realised at all.Isn''t that what happening to most games? When everything goes really slow, you can hardly control the game.Anyway, if you use DirectInput, there is a method called buffered reading. DirectInput will send the messages sent by input devices to a buffer, and your job is to read the buffer. So, in any case the frame rate drops low, if the player presses ''a'' 5 times, there will be 5 a''s in the buffer.But of course, if the buffer is full, the messages are lost. ;  Personally, I''m trying to keep the various subsystems of my engine very encapsulated. I''m planning to have my input class update the state of the key buffer, then pass the information to an input-translating object, which will handle key bindings and whatnot, then turn keypresses into game events. 