Utility function to wait specified keypress from stdin