Arduino Leonardo act as mouse?

So basically what I want to do is I realize that the Arduino Leonardo behaves and performs like it is a HID in my case a mouse. What I am looking to acheive is when a button is pressed the Arduino will send clicks to the computer, and I realize how I will code this but I have a question.

How could I make it so that when I am holding down a button on my mouse it will start clicking from the Arduino?

You'd need an application running on your computer that detects you holding the button on your mouse and sends a signal to the Leonardo. Since the Leonardo will already be connected to the computer via USB the easiest way to send that signal is probably via serial.