Advice needed on my first c# 2D jump script

I’m new to Unity and scripting in general. I am currently learning the basics and have created a simple character move script that includes jumping.

In Unity I have just drawn a couple of cube game objects to act as a platform with 2D colliders attached.

My ‘character’ is just another 2D cube that can travel left and right across the platform’s and jump by detecting the ground with a Linecast.

My problem is this: When moving the character cube along the platform and pressing the jump key I have assigned, it sometimes doesn’t jump as if it doesn’t realise I’ve pressed the jump key. It’s almost like it has to delay the next jump?

Here is my code (comments for my own learning):

sing UnityEngine;
using System.Collections;

public class PlayerController : MonoBehaviour { //this script is attached to the player game object

	//player
	public float speed; //declare the player move speed in Unity inspector
	public int jumpHeight; //this is set in the Unity Inspector
	public bool isGrounded = false; //this can be seen working in the Unity inspector
	public Transform groundedEnd; //declares the empty game object in Unity acting as a collider set to the position of the player


	void Start () {
	}

	void FixedUpdate () 
	{
		Movement (); //call the movement function below
		isGrounded = Physics2D.Linecast(this.transform.position, groundedEnd.position, 1 << LayerMask.NameToLayer("Ground")); 
		//the above line of code draws a linecast downwards to detect the ground game objects that have been placed in a ground layer
	}

	void Movement()
	{
			//Move Right
			if (Input.GetKey (KeyCode.D)) 
			{
				transform.Translate (Vector2.right * speed * Time.deltaTime);
				transform.eulerAngles = new Vector2(0,0); 
			}
			//Move Left
			if (Input.GetKey (KeyCode.A)) 
			{
				transform.Translate (Vector2.right * speed * Time.deltaTime);
				transform.eulerAngles = new Vector2(0,180); //flip the character on its x axis
			}
			//Jump by detecting if the user presses W and then checking to see if the linecast is touching the ground
			if (Input.GetKeyDown (KeyCode.W) && isGrounded == true)
			{
			//Add force to the players rigidbody allowing it to move upwards if the above if statement is true
			rigidbody2D.AddForce (Vector2.up * jumpHeight);
			}
			
	}
	
}

Here is the Unity view:

Thanks in advance for any help!!

Putting the jump part of my code in an Update function seemed to sort it out.