Making a flying camera like in the viewport ?

Hi, I’ve been working on a project and I want the camera to move freely just like in the viewport. I have started from the top down template, modified some settings and tried to replicate the same behaviour that the viewport camera has.

You can see in the picture the script for the rotation of the camera, which is where i’m having problems right now. The script works fine but it could need tweaking. First, the camera is very sensitive and it is hard to find a good value, the sensitivity can be changed by changing the arbitraty values “0.7” and “1.2” in the float multiplications but i’m wondering if there is a better way to do that.

The second problem is actually the big one, the camera is super shaky since the script reacts everytime there is a mouse movement making the camera not very comfortable to use.