keyboard: Move reusable parts to common
This is in preparation for supporting global shortcuts. The UI and logic both need to be accessed from several places. Moving it to the common area makes it simplest to include elsewhere.
This unblocks !2485 (comment 2101523)