Input problem...

I want to add to my Custom Level Editor a special function : whenever user holds a Shift key (doesn’t really matter left or right) he can more accuratly move objects (0.1 per pressing button vs 1). However, this function is not working for me… Maybe you can add your own solution and help me…

if (Input.GetKey(KeyCode.D))
            {
                foreach(GameObject t in selection)
                {

                        t.transform.position += new Vector3(1, 0, 0);

                }
            }
            else if (Input.GetKey(KeyCode.W))
            {
                foreach (GameObject t in selection)
                {

                        t.transform.position += new Vector3(0, 1, 0);

                }
            }
            else if (Input.GetKey(KeyCode.A))
            {
                foreach (GameObject t in selection)
                {

                        t.transform.position += new Vector3(-1, 0, 0);

                }
            }
            else if (Input.GetKey(KeyCode.S))
            {
                foreach (GameObject t in selection)
                {

                        t.transform.position += new Vector3(0, -1, 0);

                }
            }
            else if (Input.GetKeyDown(KeyCode.LeftShift) || Input.GetKeyDown(KeyCode.RightShift))
            {
                if (Input.GetKey(KeyCode.D))
                {
                    foreach (GameObject t in selection)
                    {

                        t.transform.position += new Vector3(0.1f, 0, 0);

                    }
                }
                else if (Input.GetKey(KeyCode.W))
                {
                    foreach (GameObject t in selection)
                    {

                        t.transform.position += new Vector3(0, 0.1f, 0);

                    }
                }
                else if (Input.GetKey(KeyCode.A))
                {
                    foreach (GameObject t in selection)
                    {

                        t.transform.position += new Vector3(-0.1f, 0, 0);

                    }
                }
                else if (Input.GetKey(KeyCode.S))
                {
                    foreach (GameObject t in selection)
                    {

                        t.transform.position += new Vector3(0, -0.1f, 0);

                    }
                }
            }

What a lot of code duplication…

float step = (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
    ? 0.1f : 1f;
        
if (Input.GetKey(KeyCode.D))    MoveSelection( Vector3.right, step );
if (Input.GetKey(KeyCode.W))    MoveSelection( Vector3.up, step );
if (Input.GetKey(KeyCode.A))    MoveSelection( Vector3.left, step );
if (Input.GetKey(KeyCode.S))    MoveSelection( Vector3.down, step );

// ...

private void MoveSelection( Vector3 direction, float step )
{
    foreach (GameObject t in selection)
        t.transform.position += direction * step;
}

So I figure it out by my own way : I added a new boolean called “shiftPressed” and check if Right or Left shift were pressed, than

shiftPressed = true;

And when user release one of this buttons:

shiftPressed = false;

And I move all my objects in selection depending on shiftPressed bool…