SFML community forums

Help => General => Topic started by: Rq on November 21, 2013, 01:41:14 pm

Title: How to catch a quick double pression ?
Post by: Rq on November 21, 2013, 01:41:14 pm
Hi,

I would like to catch a quick double pression on a single key to use a function but i cannot see how to do that.
Can you help me please ?

Thank you :)
Title: Re: How to catch a quick double pression ?
Post by: Nexus on November 21, 2013, 01:48:21 pm
With sf::Clock, you can measure the time between two presses. If it is lower than a certain threshold, perform the desired actions.
Title: Re: How to catch a quick double pression ?
Post by: wintertime on November 21, 2013, 02:24:04 pm
I would measure the time between two KeyReleased messages for same key instead, to avoid having it accidently triggered by automatic key repeat. Or alternatively measure time between a KeyReleased and the next KeyPressed message if you like to have it activated on key down.