keypress event loop working