This idiom "to keep under the hat" simply means to hide something and keep it somewhere where no one can get access to or cannot even think about that it may be in that place.
1. Will you keep this letter under your hat while you are at your home?
2. I always keep my mobile phone under my hat so that it does not get stolen.
3. I have kept your project CD under my hat, now they cannot get it.
4. That thief might have kept my ATM card under his hat, I think I won't be able to find it.