100 Horsepower on a 40 mm shaft gives a keyway shearing force of 4640 pounds. At this torque the shaft torsion shear stress is 4760 PSI, if it just drove a shaft with no overhung load. Additional stress from the pitchline of the pulley add to the shear stress of the torque load. With a small pulley, say 6 inches diameter, the maximum shear stress is 5400 PSI. Add to that figure if the pulley is some distance away from its support bearing, another additive stress.
Of course, with typical electric motors starting torque will be a multiplier of 2+/-, and then, if shock loads occur, an even higher stress multiplier.
Allowable shear stress in ordinary shafting is 18,000 PSI, and alloy shafts can have much higher stress. Just some numbers to get a quantified idea of this case.