Refactor scalar key/axis detection.