keypress if to switch