Refactor keyboard code for livecd