added basic key event loop