I first tried to replace the key. As I live in Belgium they have no stock of imperial keys only metric, so I bought a 5 x 5mm oversized and filed until it fitted on the crankshaft. Stange,it did not fit on the flywheel, so I filed half of the key to fit the flywheel. Strange that it is not a square size. The key fits now in both, but is asymmetric.
The engine doesn't make a knocking noise anymore on a first test. As it rains today I hope to cut the grass tomorrow, let's hope it stays ok. I will let you know in a few days if everything is working. Thank you very much for your help.