Born on April 12, 1757, near Charlestown, Cecil County, Province of Maryland, British America, Key pursued an academic course. He was a Loyalist during the American Revolutionary War, fighting with the British Army from 1777 to 1781. He served in the Maryland Loyalists Battalion as a captain. Key and his entire battalion were captured by the Spanish Army– who were at war with the British– in Pensacola, Florida. Key was a prisoner for a month in Havana, Cuba before being paroled and sent to New York City, New York until the end of the war. After the war, Key went to England and graduated from the Middle Temple in London in 1784 and read law in 1785. He returned to Maryland in 1785. He was admitted to the bar and entered private practice in Leonardtown, Maryland from 1787 to 1790. He continued private practice in Annapolis, Maryland from 1790 to 1794, and from 1799 to 1800. He was a member of the Maryland House of Delegates from 1794 to 1799. He was Mayor of Annapolis from 1797 to 1798.