Try not being so close to the wall when you pick it up.
Code-wise, there is a collider that checks if anything is blocking placing the object on your head. That box is apparently slightly too big and can collide with the overhang on the wall which prevents you from picking up the key. That is the only thing I manage to replicate here that prevents you from picking it up.