<
start
>
clear
copy to:
0
insert
save as:
new page
new last
delete
CSC 130
Events
Whenever you interact with your browser, you are triggering events. These events are all passed around as objects and are triggered when you perform an action like a click, mouse movement or keystroke
There is a function attached to the ellipse to the left with the following code in it: function onMouseDown(evt) { inspect(evt) } Notice the name of the function. "onMouseDown" is, obviously, an event triggered when a mouse button is pressed down. The function itself opens an inspector on the event generated by that event. Go ahead and click it and look. You'll get an inspector on the event object listing all the properties and functions associated with the onMouseDown event.
The rectangle has another function attached to it, with the following code in it: function onMouseDown(evt) { if (evt.shiftKey == true){ this.setFill(Global.Color.random()) } else { this.show() } } Notice that the event in the function contains a function that checks to see if the shift key is held down? Try clickint the rectangle with and without the shift key held down and see what happens.