handle key commands in single function