I have a cheap USB numpad that has a button for "00". Unfortunately this keypad has been made in such a way that this key isn't unique but just sends the "0" twice.
Is there a neat way to detect if a key is pressed quickly twice in succession? (debounce, is essence)
I was thinking of setting up a boolean with a timer and then checking the time between clicks, but that's bit of a "brute-force" way of doing it, or at least it feels like a duct-tape solution Is there a better way of achieving this?
The way I was thinking of doing it is about this (not tested, on the top of my head, improvising on the fly here, don't sue me for crappy code
Code: Select all
global:
boolean = false
keydown:
if boolean == true then return end
boolean = true
keyup:
if boolean = true then
send_input
timer for 500ms, set boolean = false
end
Any tips, ideas, etc?