The reason that the key is coming out is that the shaft is not far enough into the coupling or that the keyway itself is too short.
The cutter that cuts the keyway groove is radiused. The back of the keyway groove has that radius in it. The keyway should slide back till it runs up against that radius and should not go any further. If the key slides back and falls out before it reaches the radius then when the boat is on the hard, loosen the two square head bolts and slide the shaft further into the coupling. Or buy a longer key, slide the coupling forward on the shaft until you can insert the key, then re-position the coupling on the shaft
To an earlier post, I have a 1" shaft. I measured the keyway, it is .225 inches wide