Refactor keyboard layout selection