Why not setup an array and then use indexOf instead of this switch with a charCode?