This works quite well in principle, but the actor should continue rotating in a certain direction as long as the mouse is moving or the key is held down. It should only gradually slow down once the input is released.
That’s pretty much how the above works, though. Any additional behaviour will need to be scripted, ofc - holding a key would add to a target (clamped) rotator.
Another way it to simply Add Rotation in the desired direction. There really are numerous way to approach this.
However, if you’re making a spaceship flying game, want to keep it simple and avoid using physics explicitly, consider looking into the Floating Pawn Movement
component. It also works well with physics (optional), and understands player movement input.
How did you arrive at this conclusion? Are we talking about 100s / 1000s of those components? Is mobile the target platform?