move key event handlers outside of doc load