>Knocking happens from pre-detonation, that's usually caused by heat from compression causing the fuel/air mix to ignite before it's triggered by spark.
No, it usually happens because the normal flamefront from the spark causes a rise in pressure that triggers compression-ignition in other parts of the cylinder. It's not solely from the compression, usually. That scenario is rare primarily because as you reduce the knock margin, you'd hit knock from what I said before you get to the state where it's so bad it ignites from compression alone.
https://www.researchgate.net/figure/In-cylinder-pressure-tra...
Look at this picture; this is a typical waveform of cylinder pressure vs. crank angle. The spark happens 28 degrees before TDC, so basically the left edge of each of the graphs. As the flamefront consumes the air-fuel mixture inside the cylinder after the spark, the cylinder pressure gradually rises. During knock events, the cylinder pressure as risen by the normal combustion process gets to a point where it starts igniting the fuel elsewhere in the cylinder, away from the gradually expanding flamefront. This causes rapid combustion which causes the pressure to rise suddenly, which causes damage to the engine (if severe enough)