Made a simpler keyParser function

The keyParser function was kind of long so made it shorter with a validkeys object.