How to make movement on camera on button down.

Hi I need to know how to create a head bobbing movement on button down. For example I am using the First Person Controller for my game and I want it so when the player clicks the arrow keys to move, the camera will make a head bobbing movement, so that it gives the effect he is actually walking. If you can help me thank you very much i have no idea how to do this. Thanks

I dont tested it , but i think something like that should work :

void WalkingEffect() {
    GameObject MainCamera = Camera.mainCamera;
    if(MainCamera.transform.rotation.x>5){
        MainCamera.transform.rotation = Quaternion.Euler(MainCamera.transform.rotation.x++, 
        MainCamera.transform.rotation.y, MainCamera.transform.rotation.z);
    }else{
        if(MainCamera.transform.rotation.x>5){
            MainCamera.transform.rotation = Quaternion.Euler(MainCamera.transform.rotation.x--, MainCamera.transform.rotation.y, MainCamera.transform.rotation.z); 
        }
    }
}