As you described, the easiest way to do this is to install the onmousemove event handler on the body. This is cheaper than you think: very few calculations are done to store coordinates, and the event fires 50 to 100 times per second when the mouse is moved. And I suspect that the average user will not move their mouse constantly while browsing the web.
The following script helps in counting event handlers; on my machine, moving the mouse to Firefox, this added 5% to 10% to the use of my processor.
<script type="text/javascript"> jQuery(document).ready(function(){ var count = 0; $().mousemove(function(e){ count += 1; }); $().click(function(e){ $('#status').html(count); }); }); </script>
source share