At the 1904 state election, Keenan unsuccessfully contested the seat of Kalgoorlie as an independent, losing to the sitting Labor member, William Dartnell Johnson. He reversed the result at the 1905 election, standing as a Ministerialist. When Newton Moore replaced Rason as premier in May 1906, he chose Keenan to be his attorney-general. While in office, he chaired a Legislative Assemblyselect committee into Western Australia's electoral system, which recommended that the state adopt preferential voting and make various other changes. Credit for the resulting piece of legislation, the Electoral Act 1907, was largely given to Keenan, and the act is still in force. As a senior member of the government, Keenan also represented Western Australia at the 1907 Premiers' Conference. He resigned as attorney-general in May 1909, due to disagreements with the government's financial policies. Keenan did not contest the 1911 state election, with his seat being lost to Albert Green of the Labor Party. He concentrated on his law practice, having been made King's Counsel in 1908, and also served on the senate of the University of Western Australia from 1912 to 1918. After a gap of over 18 years, Keenan re-entered parliament at the 1930 state election, winning the newly created seat of Nedlands for the Nationalist Party. Just eleven days after being elected, he was included in the new ministry formed by Sir James Mitchell, taking the positions of Chief Secretary and Minister for Education. While in charge of the Education Department, Keenan made the unpopular decision to close Claremont Teachers College indefinitely, to save money during the Great Depression. He resigned from cabinet in September 1931, due to a dispute over government policy. At the 1933 state election, the Mitchell government was defeated, with Mitchell and the two other Nationalist ministers losing their seats. As he was the only remaining Nationalist in parliament with ministerial experience, a post-election party-room meeting elected Keenan as the new leader. The Nationalists had lost so many seats that they became the junior partners in the coalition with the Country Party, with the Country Party's leader, Charles Latham, serving as Leader of the Opposition. Keenan's party failed to make any improvement at the 1936 election, and he resigned as leader in April 1938 in favour of Ross McDonald. His age and health were factors in his resignation. Keenan was opposed by Dorothy Tangney, a future Labor senator, at the 1936 and 1939 elections, but retained his seat easily on both occasions. At the 1943 and 1947 elections, he did likewise, facing only independents as opponents. He had affiliated with the new Liberal Party upon its creation in 1945. Aged 86 at the time of the 1950 election, Keenan was opposed in Nedlands by three other candidates. He and one other candidate were endorsed by the Liberal Party, while the two others ran as unendorsed Liberals. Keenan polled only 23.3 percent of the first-preference vote, which was not enough to make the final two-candidate-preferred count, and the eventual victor was David Grayden, a 25-year-old leader of the party's youth wing.