Merriam-Webster:
The 1820s and 1830s shared another linguistic fad with today: an
appreciation for deliberate misspellings. (Kewl, rite?) This
trend, which had humorists adopting now-cringey bumpkin personas
with ignorance manifested in uneducated spellings, turned no go
into know go and no use into know yuse (lol). Abbreviations
were not immune, and no go became K.G.. So too all right
became O.W. , as an abbreviation for oll wright. And all
correct became o.k. , as an abbreviation for oll korrect.Although OK became one of the more commonly used initialisms, it
might have passed into oblivion when the linguistic fad had passed
if not for the presidential election of 1840, when Martin Van
Buren was given the nickname of “Old Kinderhook” because of his
hometown of Kinderhook, NY. The Van Buren stans who joined “OK
Clubs” nationwide were themselves, they proclaimed, “OK.” Their
campaign was memorable enough to have both popularized the word
and to have hijacked the story of its origin: there are today
still those who believe that “Old Kinderhook” is the original
meaning of OK.
I have a strong preference for OK (perhaps infused by the classic Macintosh Human Interface Guidelines’s adamance on the spelling). Okay is OK in prose, but never as a UI button label. Ok and ok are not OK.
