Problem with jumping

I am currently making a 2D game but I have a problem with jumping. I want my character to be able to jump only one time before he is grounded again. Here is my script:

    public var jumpPower : float = 1000.0f;
    private var canJump : boolean = true;
        
    function Update()
    {
        if (Input.GetKeyDown("w"))
        	{
                   if(canJump == true)
        		{
        			rigidbody2D.AddForce (transform.up * jumpPower);
        			canJump = false;
        		}
        
        		
        	}
        }
        
        
     function OnCollisionEnter2D(coll: Collision2D)
        {
        	if(coll.gameObject.tag == "Ground")
        	{
        		canJump = true;
        	}
        }

The cubes ,on which the player lands, are tag as “Ground”.

There are multiple tutorials, here is an easy one with mid-air movement (left/right):

using UnityEngine;
using System.Collections;

public class MovementWorm3 : MonoBehaviour {
	
	float speed     = 6.0f;
	float jumpSpeed = 8.0f;
	float gravity   = 20.0f;

	private Vector3 moveDirection = Vector3.zero;
	private CharacterController controller;

	// Use this for initialization
	void Start () {
		controller = GetComponent<CharacterController>();	
	}
	
	// Update is called once per frame
	void Update () {
			
		if (controller.isGrounded) {
		    // We are grounded, so recalculate
			// move direction directly from axes		
			moveDirection = new Vector3(Input.GetAxis ("Horizontal"), 0, 0);
			moveDirection = transform.TransformDirection(moveDirection);
			moveDirection = moveDirection * speed;

		    if (Input.GetButton ("Jump")) {
		        moveDirection.y = jumpSpeed;
		    }
		}
		else {
			// Apply right/left, if we are NOT grounded
			// --> Left/Right movement in mid air allowed
			moveDirection.x = Input.GetAxis ("Horizontal") * speed;
		}

		// Apply gravity
		moveDirection.y -= gravity * Time.deltaTime;
		
		// Move the controller
		controller.Move(moveDirection * Time.deltaTime);
	}
}