when it happened to me, I squirted some WD40 in the actual key slot and opperated the key several times, it the key is not in the right poosition when you remove it then it just springs back open.
If its the bonnet switch or the door switch then ususaly the horn sounds when you try to lock it with the fob.