For pre-detonation all engines have a knock sensor. This sensor identifies detonation long before you would notice it and retards timing to stop it.