Improve decouple key handling to input algorithm