# ReUse MouseEvent Functons

**URL:** https://forum.kirupa.com/t/reuse-mouseevent-functons/284971
**Category:** flash
**Created:** [March 25, 2009, 5:42pm UTC](https://forum.kirupa.com/t/reuse-mouseevent-functons/284971 "2009-03-25T17:42:02Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![ThaJock](https://avatars.discourse-cdn.com/v4/letter/t/9de0a6/32.png) [@ThaJock](https://forum.kirupa.com/u/ThaJock)
#### Post date: [March 25, 2009, 5:42pm UTC](https://forum.kirupa.com/t/reuse-mouseevent-functons/284971/1 "2009-03-25T17:42:02Z")

</div>

I am trying to avoid having to rewrite a few functions that I use for mouseEvents that I am going to also have to use for keyBoard events.

eg.

btn.addEventListener (event:MouseEvent.CLICK,btnClick);  
stage.addEventListener(KeyboardEvent.KEY\_DOWN, EnterBtn);

function btnClick (event:MouseEvent):void {  
trace(‘do somethin’);  
}

function EnterBtn (event:keyBoard):void {  
if (event.keyCode == 13){  
[COLOR=Red]btnClick();[/COLOR]  
}  
}

I want to invoke the same function if I Click btn or if I hit enter on the keyBoard.  
This code won’t work because btnClick it requires an argument.  
How do I set up a function to be used for MouseEvents or keyBoardEvents?  
The only way I know how is to create a new function and past the code from btnClick function into the EnterBtn function but I wouldn’t really be learning anything new.

Any help would be appreciated.
