strowger.event
Functions for managing DOM events.
add-listeners
(add-listeners element key listeners)
Add a map of event keywords to listener functions to a DOM element. The key argument is a unique value used to identify the listeners so that they can be removed using remove-listeners.
client-xy
(client-xy event)
Return the client X and Y coordinates of an event as an [x y]
vector.
event-button
(event-button event)
Return the name of the button clicked on a :click
or :dblclick
event.
event-key
(event-key event)
Return the name of the key pressed on a :keyup
, :keydown
or :keypress
event.
offset-xy
(offset-xy event)
Return the offset X and Y coordinate of an event as an [x y]
vector. This function forces adherance to the W3C standard, avoiding cross-browser issues with .-offsetX
and .-offsetY
.
remove-listeners
(remove-listeners element key)
Remove all the listeners on a DOM element associated with the supplied key. See add-listeners.