Use document/window from event target instead of global

Fixes #427

Test plan: not yet/will test our application on the browsers I have access to
Is this "old IE textarea" still accurate?