One fine day I was working in my office, developing my first big game Rummy. And my boss comes and tells me “dude, I want a feature in the game where players should be able to discard a card by selecting it and pressing on the discard button and if they want they can simply double-click to discard a card ”.  No big deal, there is an event listener MouseEvent.CLICK and MouseEvent.DOUBLE_CLICK for single-click and double-click respectively. The only problem is they don’t work simultaneously :( .

Well nothing is impossible :)

Before I get into how it works, lets take a look on a simple code snippet.