The polling approach is already used in the YUI2' onAvailable method.
http://yui.yahooapis.com/2.9.0/build/event/event.js
But your code should be faster -because you are polling at the 5ms interval!
But your code should be faster -because you are polling at the 5ms interval!