After the end of World War II, many leaders in Ghana agitated for independence from Britain. Their methods included strikes, boycots, protests, and other forms of civil and mostly non-violent disobedience. Eventually, one of the main leaders, Kwame Nkrumah won a majority of seats in the legislature and eventually forced Britain to concede independence at the negotiating table.
Much of what led to Kenya's independence, on the other hand, was actually built upon a very violent rebellion and continued open resistance to British rule. After a relatively strong Kenyan Army was built and trained to help defeat the Mau Mau Rebellion, the election of a Kenyan majority in government helped to then bring about the independence of Kenya from the British.
Both countries eventually gained power through elections within legislatures or parliaments of pro-independence parties and those who lobbied for a strong and independent African nation.