SFML community forums

Help => Window => Topic started by: dotty on January 25, 2012, 05:37:39 pm

Title: logging a series of key presses
Post by: dotty on January 25, 2012, 05:37:39 pm
Hay, I'm wondering what peoples thoughts are solving my problem.
 I want to develop a system that records a series of button presses.
These act like a "combo" on many platform games.
Say i press the keys L,O,P very quickly, that would preform a certain action.
 These 'combos' are going to be stored in an array like int[LKEYCODE, OKEYCODE, PKEYCODE].
However I want to these to only match if the time between each key press is < 0.5 seconds.

How would one go about creating something like this?
Title: logging a series of key presses
Post by: RedIrony on January 25, 2012, 06:54:05 pm
Sounds like you could just create a clock with the array, and reset the clock each time a keystroke is added to the array. If the clock is greater than 0.5s when the stroke is added, you flush the array before you add the keystroke.

If you know the length of all combos will be a certain length, you can use that to check to see whether a combo is being formed, or whether you just have junk values.