# Calling a function used on eventListeners elsewhere

**URL:** <https://forum.kirupa.com/t/calling-a-function-used-on-eventlisteners-elsewhere/291175>\
**Category:** Uncategorized\
**Created:** [June 25, 2009, 7:42pm UTC](https://forum.kirupa.com/t/calling-a-function-used-on-eventlisteners-elsewhere/291175 "2009-06-25T19:42:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mistermind](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Mistermind](https://forum.kirupa.com/u/Mistermind)\
**Post date:** [June 25, 2009, 7:42pm UTC](https://forum.kirupa.com/t/calling-a-function-used-on-eventlisteners-elsewhere/291175/1 "2009-06-25T19:42:50Z")

</div>

Hello there fellow wizards!

I got a pickle for you:  
I have a function that is currently connected to an event listener like this:

```auto
loginButton.addEventListener(MouseEvent.CLICK, loginOnClick, false, 0, true);
function loginOnClick(event:MouseEvent):void{
   // Login code.
}

```

Right now I’d also like to call that same function using the ENTER from a keyboard since loginOnClick doesn’t use the parameter received (event:MouseEvent). So I did this:

```auto
function keyboardListener(event:KeyboardEvent):void{
if (loginButton){
   if (event.keyCode == Keyboard.ENTER && loginButton.enabled) {
       loginOnClick(); // Generates an error because it doesn't have a parameter.
   }
}
usernameTextField.addEventListener(KeyboardEvent.KEY_DOWN,keyboardListener);

```

Problem is, of course, AS3 doesn’t let you call a function with the incorrect number of parameters or types.  
I tried following senocula’s tutorials on functions and parameters but they don’t seem to work on this very specific issue considering the parameter is an event reference.

Is there a solution for this or do I have to make a new function with the same code just for that?

Cheers!
