What were the circumstances that allowed Francis Scott Key to write the Star Spangled Banner?

he wrote the the star spangled banner