This is incorrect. You can’t be held in contempt for failing to comply with an order you can’t comply with, for example due to a loss of memory. In this case the court did not believe that the defendant had forgotten the key.
Whether you actually have lost your memory is a factual question to be determined by a trier of fact. Generally, most triers of fact rule against the forgettor if forgetting benefits them.
OTOH, if a witness forgets, they would not be held in court, because there's no benefit to them forgetting, and so their loss of memory is believable.
OTOH, if a witness forgets, they would not be held in court, because there's no benefit to them forgetting, and so their loss of memory is believable.