You are on page 1of 14

HELLO EVENTS

Lesson Two: Mouse events


Outcomes :
In the end of this lesson you will be able to do the
following :
1- Explore and use Keyboard and mouse events in small
basic
Revision Questions!

Warm up!
Exercises
Q1) Raises an event when we press a key on the keyboard

A . Keyup

B. Keypress

C. keydown
Q2) Runs a sub named S2 when the key is released.

A. Graphicswindow.keyrelease=S2

B. Graphicswindow.Keyup=S2

C. Graphicswindow.Keydown=S3
Q3) find the errors in the following code

Q4) after correcting the errors. What is the result of the code?
Keyboard Events

KeyDown KeyUp

Raises an event When you press a Raises an event When you release
key on the keyboard, the key
Keyboard Events

1 KeyDown:

2 KeyUp:
Example on keyboard events
the program below will add a green
rectangle with a blue pen color in a
random place when we press a key on
the keyboard.
Mouse Events

MouseDown MouseUp MouseMove


Mouse Events

MouseDown MouseUp MouseMove

Raises an event When you Raises an event When you Raises an event When you
click on the mouse button release the mouse button move your mouse
Can you guess the result of the
following code?
Lesson Task :
write a program that: adds
a yellow square in a
random location whenever
you click the mouse button
Lesson Task :
write a program that: adds
a red ellipse in a random
location whenever you
press any key on your
keyboard!
And
adds a yellow square in a
random location whenever
you click the mouse button

You might also like