I would like to refer you to the documentation of racket: Guide to the racket graphical interface toolkit
There you will learn how to handle all kind of events. You could also try the 'How to Design Programs Teachpacks'.