When I'm leaving keys I imagine myself going back and searching for them and remembering that I left them there.
Then when I really am in this situation I remember the false memory and find them :)
Same thing works with remembering to buy something when going back from work and other "do THIS when THAT". When I decide I have to buy X I imagine myself stepping out of the bus, going up the stairs, remembering to go to the shop, turning and going there.
Then when I really do this I remember to turn :) What's funny is that a few times I then decided to go out on the next stop (a little longer walk but less mud when it's raining) - and I haven't remembered because the trigger didn't happen :)
I find it just easier to develop a protocol on where the keys go. In fact, I organize my entire space so that everything has a place and as soon as I am done with it I put it back in the place. Reduces cognitive load. Since a thing is in a place every time, eventually my brain builds a detailed map of exactly where everything lives, even down to the inch within a shelf, drawer, etc. At this point I could almost operate blind.
Therein lies the rub...
I get the same feeling working on a shared codebase...where'd I put that dang function now...