Key was not himself a POW, Big Dog. He was a negotiator.
During the War of 1812, Key, accompanied by the British Prisoner Exchange Agent Colonel John Stuart Skinner, dined aboard the British ship HMS Tonnant as the guests of three British officers: Vice Admiral Alexander Cochrane, Rear Admiral George Cockburn, and Major General Robert Ross.
Skinner and Key were there to negotiate the release of prisoners, one of whom was Dr. William Beanes, a resident of Upper Marlboro, Maryland, who had been arrested after jailing marauding British troops who were looting local farms. Skinner, Key, and Beanes were not allowed to return to their own sloop because they had become familiar with the strength and position of the British units and with the British intent to attack Baltimore.
Thus, Key was unable to do anything but watch the bombardment of the American forces at Fort McHenry during the Battle of Baltimore on the night of September 13–14, 1814.
At dawn, Key was able to see an American flag still waving. Back in Baltimore and inspired, Key wrote a poem about his experience, "Defense of Fort M'Henry", which was soon published in William Pechin's American and Commercial Daily Advertiser on September 21, 1814.
He took it to Thomas Carr, a music publisher, who adapted it to the rhythms of composer John Stafford Smith's "To Anacreon in Heaven", a popular tune Key had already used as a setting for his 1805-song "When the Warrior Returns", celebrating U.S. heroes of the First Barbary War. (Key used the "star-spangled" flag imagery in the earlier song).