generic handling of key presses