refactored to support capture + dispatch on window
Merge pull request #1 from ondras/master

refactored to support capture + dispatch on window