Generally, cash for keys is a program where the bank pays you to leave to avoid a costly and lengthy eviction AFTER they foreclosed on the home, so I'm a little confused by what your situation is. Perhaps you did a friendly foreclosure?
However it was recorded is immaterial in this situation. The big question is how it was reported to the credit bureaus. Talk to a mortgage company and try to get pre-approved. They will be able to tell you what's on your credit report and whether you can buy now or how long it might take to get approved. I put a website below of a lender with whom I work. Give them a call and explain your situation to them.