separated key event handling from main server code