Your Browser (Chrome, IE, Safari, Firefox) has a loop going that is always checking for certain events. These events include mouse clicks (right, left, double), key presses, and even the mouse moving, as well as many others.
Here is a list of events. It's overwhelmingly long, so let's focus on