Use jquery event rather than global window event