Unity C# WaitForSeconds Not Working

I am making a game where a monster takes windows away and opens random notepad windows but when I use the WaitForSeconds function, it doesn’t wait. Here is the code:

using System.Collections;
using System.Collections.Generic;
using Desktopia;
using UnityEngine;

public class movement : MonoBehaviour
{
    public float jumpHeight;
    public int movementspeed = 4;
    private bool isJumping = false;
    private Rigidbody2D _rigidBody2D;

    void Start()
    {
        _rigidBody2D = GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.J))
        {
            for (int i = 0; i < 40; i++)
            {
                transform.Translate(new Vector3(1.0f, 0.0f, 0.0f) * movementspeed * Time.deltaTime);
            }
            System.Diagnostics.Process.Start("notepad.exe");
            Sleep(1);
            Sleep(1);
            Sleep(1);
            Sleep(1);
        }
        if (_rigidBody2D.velocity.y == 0)
        {
            isJumping = false;
        }
        if (Input.GetKey(KeyCode.Space) && !isJumping)
        {
            _rigidBody2D.AddForce(Vector2.up * jumpHeight);

            isJumping = true;
        }
    }

    void Sleep(float time)
    {
        StartCoroutine(Delay(time));
    }

    IEnumerator Delay(float seconds)
    {
        yield return new WaitForSeconds(seconds);
        Desktopia.Windows.Main.Move(40, 40);
    }
}

I’m a noob but don’t you need to put seconds here?

     yield return new WaitForSeconds(seconds);

maybe it should be like this?

     yield return new WaitForSeconds(5); 

if you want to wait 5 seconds

This is how you should be calling your coroutine:

using System.Collections;
using UnityEngine;

public class NewWaitForSeconds : MonoBehaviour
{
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.J)) // Using KeyDown
        {
            Sleep(1f);
        }
    }

    void Sleep(float time)
    {
        StartCoroutine(CO_Sleep(time));
    }

    IEnumerator CO_Sleep(float seconds)
    {
        yield return new WaitForSeconds(seconds);
        // Move window
    }
}

And this is an alternative method that starts a time counter using the float toSleepTime and does what I think you intend to do (Added Debug.Log to each step so you know what’s happening).

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DeltaTimeWait : MonoBehaviour
{
    public float moveSpeed = 2;
    public float waitTimeToSleep = 1f;
    private float toSleepTime;
    private bool isGoingToSleep;

    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.J))
        {
            Debug.Log("Start isGoingToSleep");
            /* Notepad.exe goes here and I'm not sure
               how this behaves, if it should follow the character
               maybe you should think about parenting it to this gameobject
               and unparenting when the action ends and Sleep() is called.
             */
            isGoingToSleep = true; // true to start counting sleepTime
        }

        if (isGoingToSleep) // if true start counting
        {
            Debug.Log("Updating isGoingToSleep");
            float t = Time.deltaTime; // store deltaTime to reuse it

            // this will move until sleepTime reaches sleepDelayTime
            transform.Translate(new Vector3(1.0f, 0.0f, 0.0f) * moveSpeed * t); 

            toSleepTime += t; // start adding deltaTime to sleepTime

            if (toSleepTime >= waitTimeToSleep)
            {
                Debug.Log("End isGoingToSleep");
                Sleep(); // call the method once
                isGoingToSleep = false; // stop this action
                toSleepTime = 0.0f; // to make it start from zero the next time it's called
            }
        }
    }

    private void Sleep()
    {
        // Move window
    }
}