How do I rotate player's camera to peak around objects. (first person shooter leaning)

After about 2-3 years of doing just 3D modeling and not really getting anywhere with my games, I decided to start learning programming. I know a bit of UnityScript(Java) and even less of C#. I decided to test out my knowledge of programming by making a script called Peaking for both C# and Java as tests. I then left C# alone as I got confused so in one section of code(for Java), I typed:

if(Input.GetKeyDown(KeyCode.E))
Transform.Rotate(0, 0, 1);

The console then gave me an error saying: "An instance of type ‘UnityEngine.Transform’ is required to access non static member ‘Rotate’.:

I then messed around a bit and came up with this script:

function Update ()
{
if(Input.GetKeyDown(KeyCode.E))
transform.Translate(1, 0, 0);

if(Input.GetKeyUp(KeyCode.E))
    transform.Translate(-1, 0, 0);

if(Input.GetKeyDown(KeyCode.Q))
    transform.Translate(-1, 0, 0);

if(Input.GetKeyUp(KeyCode.Q))
    transform.Translate(1, 0, 0);

}

What I’m basically trying to do is rotate the camera along the Z axis to simulate the peaking effect going around a corner instead of making the head shift to the side like I did.

Firstly, each movement has to be made according to the frame rate. Update is a function which is called each frame, and according to the frame rate, you will have to make your character move more or less. Usually, it will look like:

     if(Input.GetKey(KeyCode.W))
         transform.Translate(0, 0, Time.deltaTime * speed);
    if(Input.GetKey(KeyCode.S))
         transform.Translate(0, 0, -Time.deltaTime * speed);
    if(Input.GetKey(KeyCode.A))
         transform.Translate(Time.deltaTime * speed, 0, 0);
    if(Input.GetKey(KeyCode.D))
         transform.Translate(-Time.deltaTime * speed, 0, 0);

This code can be simplified, but this one is explicit.

Then to make your character to rotate, you need to go to Edit > Project settings > Input and you will see (“Mouse X” and “Mouse Y”). It enables you to write:

         transform.Rotate(0, 0, Input.GetAxis("Mouse X"));

And you will be able to set the sensitivity (°/pixel) in the Input settings.

In the Input settings, you can see “Horizontal” and “Vertcial” too. It enables to simplify the translation script:

         transform.Translate(Input.GetAxis("Horizontal") * speed * Time.deltaTime, 0, Input.GetAxis("Vertical") * speed * Time.deltaTime);