Attach event to document and not window