# Case statement

**URL:** <https://forum.kirupa.com/t/case-statement/283411>\
**Category:** Uncategorized\
**Created:** [March 5, 2009, 7:44pm UTC](https://forum.kirupa.com/t/case-statement/283411 "2009-03-05T19:44:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![autumnmedia](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@autumnmedia](https://forum.kirupa.com/u/autumnmedia)\
**Post date:** [March 5, 2009, 7:44pm UTC](https://forum.kirupa.com/t/case-statement/283411/1 "2009-03-05T19:44:22Z")

</div>

I have a case statement that detects what key has been pressed on a keyboard,  
at the moment i have four different cases for four different letters,  
how would i go about making a case that changes depending on what key is pressed,  
for example, i have letters falling down the screen, and i need it so that if there is an R on screen the user has to press an R etc…

at the moment im using,

```auto
override function keyDownHandler(e:KeyboardEvent):void { //override any other key operations
    switch (String.fromCharCode(e.keyCode)) { //switch statement checks letter pressed in
        case 'T' : //if T is pressed
            for (var i:uint=removeNum; i<clip; i++) {
                hitTarget = this.getChildByName("letter"+i); //gets the correct letter clip
                if (hitTarget.hitTestPoint(leftSmall.x, leftSmall.y, true)) { //if its hit the perfect circle
                    removeChild(hitTarget); //remove the clip
                    removeNum++; //add one to numebr removed
                    small=true; //small true
                    score+=10; //add to the score
                    energy.gotoAndPlay(energy.currentFrame-40); //increase energy
                    perfectClip.gotoAndPlay(2); //play the perfect clip
                    return; //exit
                }

```

any suggestions at all?
