Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How to catch a quick double pression ?  (Read 1248 times)

0 Members and 1 Guest are viewing this topic.

Rq

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
How to catch a quick double pression ?
« 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 :)

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: How to catch a quick double pression ?
« Reply #1 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.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

wintertime

  • Sr. Member
  • ****
  • Posts: 255
    • View Profile
Re: How to catch a quick double pression ?
« Reply #2 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.