Page 1 of 1

How to get double-tap

Posted: Tue Oct 05, 2021 1:23 pm
by Gunroar:Cannon()
Just wondering how one would go about getting a double tap (with keys), instead of it registering as a single tap?

Re: How to get double-tap

Posted: Tue Oct 05, 2021 1:56 pm
by milon
If you're talking keyboard, I believe you have to manually check for that. Here's one way:
Use love.keypressed to register key presses in a table, and also store a timer in it. When a key is pressed, check the timer. If it's a short enough time span, call your "double tap" function. Otherwise, update the key's timer in the table, and optionally call your single-press function (or wait until the timer expires, then decided if it's single or double).

Re: How to get double-tap

Posted: Tue Oct 05, 2021 3:05 pm
by darkfrei
For mouse:

Code: Select all

function love.draw()
	love.graphics.print (tostring(mousepressed_presses), 0, 40)
	love.graphics.print (tostring(mousereleased_presses), 0, 80)
end

function love.mousepressed( x, y, button, istouch, presses )
	mousepressed_presses = presses
end

function love.mousereleased( x, y, button, istouch, presses )
	mousereleased_presses = presses
end