Event Handler Logic

Is there some way to combine event handler functions logically? I want the same thing to happen in each of these instances:

function OnMouseEnter() {if (Input.anyKey)}

or

function OnMouseOver() {if (Input.anyKeyDown)}

I can just copy the code from one function to the other, but I suspect there may be a better way.

Maybe just create your own function.

function OnMouseEnter ()
{
      MyFunction ();
}

function OnMouseOver ()
{
      MyFunction ();
}

function MyFunction ()
{
      if (Input.anyKeyDown)
      {
          // Do something.
      }
}

That was really close to what I needed. Thanks a bunch! Here’s the meat of what I came up with (It would be nicer to just use a “||”):

function OnMouseEnter() {
	if (Input.anyKey){
		myFunction();
	}
}

function OnMouseOver() {
	if (Input.anyKeyDown){
		myFunction();
	}
}		

function myFunction(){
	//do something
}