# Problems with Listeners and keys?

**URL:** <https://forum.kirupa.com/t/problems-with-listeners-and-keys/286592>\
**Category:** Uncategorized\
**Created:** [April 17, 2009, 1:20pm UTC](https://forum.kirupa.com/t/problems-with-listeners-and-keys/286592 "2009-04-17T13:20:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sivant](https://avatars.discourse-cdn.com/v4/letter/s/cc9497/32.png) [@sivant](https://forum.kirupa.com/u/sivant)\
**Post date:** [April 17, 2009, 1:20pm UTC](https://forum.kirupa.com/t/problems-with-listeners-and-keys/286592/1 "2009-04-17T13:20:13Z")

</div>

i have three input textfields(quest1,quest2,quest3) where the user is suppose to type in a number. if he types in the correct number he gets 5 points, if he doesnt i reset the variable that holds the points to zero.  
i created a movieclip and added a Listener to it :

```auto

this.createEmptyMovieClip("_keyListener", 1);
Key.addListener(_keyListener);
_keyListener.onKeyDown = function() {
 if (quest1 == 3) {
  quest1Score = 5;
 } else {
  quest1Score = 0;
 }
 if (quest2 == 5) {
  quest2Score = 5;
 } else {
  quest2Score = 0;
 }
 if (quest3 == 10) {
  quest3Score = 5;
 } else {
  quest3Score = 0;
 }
 nextTestBtn.enabled = true;
 nextTestBtn.gotoAndStop(1);
};

```

i can check it with the nextTestBtn button with trace . and what happens is that it never gets the score of the last inputTextField.  
what can i do?  
here is the code that comes before the above listener code:

```auto

stop();
//next two lines disables the next Btn
nextTestBtn.gotoAndStop(3);
nextTestBtn.enabled = false;
//next 3 lines for keeping the grade for each question
var quest1:Number = 0;
var quest2:Number = 0;
var quest3:Number = 0;
var quest1Score:Number = 0;
var quest2Score:Number = 0;
var quest3Score:Number = 0;
//for adding the grade from the three questions
var totalScore = 0;
///////////
//nextTestBtn will be enabled after questAnswer>3
nextTestBtn.onRelease = function() {
 totalScore = quest1Score+quest2Score+quest3Score;
 play();
 trace("quest1Score:"+quest1Score);
 trace("quest2Score:"+quest2Score);
 trace("quest3Score:"+quest3Score);
 trace("quest1:"+quest1);
 trace("quest2:"+quest2);
 trace("quest3:"+quest3);
};

```

HELP ANYONE???!!
