Code to detect single or double click

Sure, agree. A double click isn't a well behaved method. I hate it. It limits the speed of successive single presses and/or contributes to user errors.