Who was president when Francis Key wrote the Star Spangled Banner?

That was James Madison.