I’m trying to call a function when the mouse moves within the body of the document. However, the below event handler is not working.
goog.events.listen(document,
'onmousemove',
function(e) {console.log('foo');});
Why isn’t it working? I’ve tried window instead of document as well.
onmousemoveis an element property. The DOM event you are looking for ismousemove. See the MDN DOM event reference.The Closure Library provides the cross-browser event API
goog.events.EventType, which has the added benefit of preventing typos. Using this enum, your code would be written: