implement key switching