Add event callback scope in all event-related functions

Add the ability to bind an event listener function to a certain
(optional) scope. Since the element was the default scope, also added
the element as a parameter to the function being called.