# Button and keyboard event

**URL:** <https://forum.kirupa.com/t/button-and-keyboard-event/330983>\
**Category:** Uncategorized\
**Created:** [April 20, 2013, 5:34pm UTC](https://forum.kirupa.com/t/button-and-keyboard-event/330983 "2013-04-20T17:34:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![harry1](https://avatars.discourse-cdn.com/v4/letter/h/919ad9/32.png) [@harry1](https://forum.kirupa.com/u/harry1)\
**Post date:** [April 20, 2013, 5:34pm UTC](https://forum.kirupa.com/t/button-and-keyboard-event/330983/1 "2013-04-20T17:34:59Z")

</div>

I have created a login form. On stage I have two text input fields and a button. I want the user to login by clicking the button or, by pressing Enter on the keyboard. Coming from AS2 I am not sure what the best approach is. Do I have to fire both input fields or just one? This is my code please tell me what I am doing wrong? Thanks inputfieldOne.addEventListener(MouseEvent.CLICK, btnSubmit); inputfieldOne.addEventListener(KeyboardEvent.KEY\_DOWN, keyHandler); function btnSubmit(event:MouseEvent):void{ trace(“Login”); function keyHandler(event:KeyboardEvent):void{ if(event.keyCode == Keyboard.ENTER) trace(“keyboard was pressed”);
