ui button function and onclick event

how can i give this ui button an onclick event as well as a keyboard return key ,i think i am not being clear enough ,i want my game to have the same function when i click return and when i click the button on screen ,i for keyboard return one for screen button ,basically how can i give 2 key for same function` public Transform eggpoint;

%|-1560315035_1|%

void Start()
{

}

// Update is called once per frame
void Update()
{
    if (Input.GetKeyUp("space") || Input.GetMouseButtonDown(0))
    {
        GetComponent<Rigidbody2D>().velocity = Vector2.zero;
        GetComponent<Rigidbody2D>().AddForce(jumpForce);
    }
        if(Input.GetKeyDown(KeyCode.Return))
        {
            Instantiate(Egg, eggpoint.position, eggpoint.rotation);

%|657980421_16|%

%|69678579_17|%
%|1246395602_18|%
}`

as you can see i have instantiate function above and now i have the return key from keyboard to execute this fucntion i want my ui button to have the same function how can i achieve this.

Just create a public function that does the same…

public void LayEgg()
{
     Instantiate(Egg, eggpoint.position, eggpoint.rotation);
}

Then on the button click + in the OnClick, drag the object that your script is on to the slot that appears and select YourScriptName → LayEgg from the drop down.

It makes sense to call that function from you key input as well so any changes you make only need to be made i one location.