why did fancis scot key write The Star-Spangled Banner?

Francis Scott Key wrote The Star-Spangled Banner during the War of 1812. The poem was originally titled "Defence of Fort M'Henry" and was inspired by Key's experience witnessing the British bombardment of Fort McHenry in Baltimore, Maryland. Key was on a ship negotiating the release of American prisoners held by the British at the time. When he saw the American flag still flying proudly over the fort after the intense battle, it filled him with a sense of patriotic pride and inspired him to write the poem. The poem later became the lyrics for the United States' national anthem, The Star-Spangled Banner.