Reverted input code and implemented keystate in gm instead