How can I have a bullet travel a constant distance in the direction of the cursor?

Before you calculate the direction and rotation vectors for your bullet, try changing the Y coordinate of the mouse position you get to the Y coordinate of the character position:

Based on your previous comment that the world direction of a mouse click is “x=0, y = -1, z = 0” it seems like you would want your projectile to move only along the X Z plane.