That’s basically the same code with a button that triggers a led when pushed.
Instead of the button you have the laser sensor.
Lighting the LED means setting a pin HIGH which is the TTL signal you are looking for
Does your camera take a picture or a movie? If it’s a picture then there might be a small delay you need to implement between the detection of the hammer crossing the laser beam versus hitting the surface (if this is the picture you want to take)
If it’s a movie, You’ll need to decide how long the Pin stays HIGH