Why did Francis Scott Key write "The Star-Spangled Banner"?

O He thought the Americans had surrendered.

O He had been asked to write a national anthem.

O He was inspired by American soldiers.

O He was happy the war had come to an end.