He was the son of Geza I of Hungary and Zs?ia (Sophia).
L?zl?I wanted K?m?'s brother ?mos to succeed him as King of Hungary. (According to the chronicles, K?m? may have had a physical deformity, which would have made him unfit to be king per medieval beliefs about such things.) Not wanting to abandon his eldest nephew completely, he wished instead to make him a bishop. K?m? was accordingly sent abroad to acquire his subsequently famous learning, which earned him the appellation "K?yves", or "Bookish". (At the time, this was not a compliment. History has been kind to K?m?, however, so modern histories are more apt to translate the nickname as "The Wise" or similar.)
The exact circumstances of how K?m? acquired the throne after L?zl?s death are unknown; among other difficulties, he may have had to get papal dispensation, because ordained clergy could not become king. (The sources are unclear on whether K?m? was actually ordained. His later laws show that he had no problem with married clergy, so his eventual marriages are no evidence in this matter.)
L?zl?died before he could fulfill his promise of leading a Crusade. K?m? did not find it necessary to fulfill the promise of his predecessor, but did concede at first to let the crusading armies go through Hungary. When the first such army (1096) proceded to pillage its way through the country, he put greater and greater restrictions on subsequent armies, such as taking hostages and mustering his own army to guard the progress. (Needless to say, these actions did not endear him to contemporary chroniclers; that's why we don't know if those descriptions of an ugly, hairy, crosseyed man are true or, um, slightly exaggerated.)
K?m? changed Hungary's foreign policy: while L?zl?I. had asked for the Holy Roman Emperor's help (instead of the pope's) when waging war on Croatia, K?m? wanted to stay on good terms with the Holy See. This didn't prevent him from subjugating Croatia, nor from conquering Dalmatia ahead of the similarly-inclined Venetians. The pope eventually acceded him the right of appointing bishops.
K?m?'s court was a center of learning and literature. Bishop Hartvik's Life of St. Stephen, a chronicle of Hungary, the shorter of the extant Legends of St. Gell?t, and several collections of laws all stem from his reign. One of his most famous laws was half a millennium ahead of its time: De strigis vero quae non sunt, nulla amplius quaestio fiat (As for the matter of witches [more exacly "strigas", which isn't exactly the same as "witch"], there is no such thing, therefore no further investigations or trials are to be held).
?mos made several attempts to take over K?m?'s throne, but all were unsuccessful. After repeatedly forgiving his wayward brother, K?m? was finally forced to bring justice against him in 1115, although even then he commuted the familial death sentence required by law to the sentence of blinding ?mos and his young son B?a.
K?m? died February 3, 1116. He was buried in Sz?esfeh?v?, next to St. Stephen.
He married twice, first to Busila, daughter of Roger I of Sicily, and second to Eufemia, daughter of Vladimir II of Kiev. He had four children: