Code for discering single from double clicks