This is one of the activities that I did when taking a Processing JS class on Khan Academy.  In this program, I learned how to track the mouse and place certain colored dots when moving the mouse and different colored dots when clicking and moving the mouse