# Key Press to match MC.text

**URL:** <https://forum.kirupa.com/t/key-press-to-match-mc-text/258321>\
**Category:** flash\
**Created:** [April 23, 2008, 2:27am UTC](https://forum.kirupa.com/t/key-press-to-match-mc-text/258321 "2008-04-23T02:27:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![specialboy](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@specialboy](https://forum.kirupa.com/u/specialboy)\
**Post date:** [April 23, 2008, 2:27am UTC](https://forum.kirupa.com/t/key-press-to-match-mc-text/258321/1 "2008-04-23T02:27:23Z")

</div>

I’m having trouble with the code to match a key press and what’s in an MC.

The MC is called letter and the text box in it is called txt. When it appears on the screen I want the user to press the key of the letter in the box, but I am having issues.

ActionScript Code:  
[FONT=Courier New][LEFT]\</p\>  
\<p\>var myLetter = letter.[COLOR=#000080]txt[/COLOR].[COLOR=#0000ff]text[/COLOR];\</p\>  
\<p\>&nbsp;\</p\>  
\<p\>this.[COLOR=#0000ff]onKeyDown[/COLOR] = [COLOR=#000000] **function** [/COLOR]COLOR=#000000[/COLOR]\</p\>  
\<p\>[COLOR=#000000]{[/COLOR]\</p\>  
\<p\> [COLOR=#0000ff]if[/COLOR][COLOR=#000000]([/COLOR]COLOR=#000000[/COLOR] == [COLOR=#ff0000]“g”[/COLOR][COLOR=#000000])[/COLOR]\</p\>  
\<p\> [COLOR=#000000]{[/COLOR]\</p\>  
\<p\> [COLOR=#0000ff]trace[/COLOR]COLOR=#000000[/COLOR]; [COLOR=#808080]_// = 71\</p\>_[/COLOR]  
\<p\> [COLOR=#0000ff]trace[/COLOR]COLOR=#000000[/COLOR]; [COLOR=#808080]_// = G\</p\>_[/COLOR]  
\<p\> [COLOR=#0000ff]trace[/COLOR]COLOR=#000000[/COLOR]; [COLOR=#808080]_// = G\</p\>_[/COLOR]  
\<p\> [COLOR=#0000ff]if[/COLOR][COLOR=#000000]([/COLOR]myLetter == [COLOR=#0000ff]Key[/COLOR].[COLOR=#0000ff]getCode[/COLOR]COLOR=#000000[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR][COLOR=#0000ff]trace[/COLOR]COLOR=#000000[/COLOR];[COLOR=#000000]}[/COLOR]\</p\>  
\<p\> [COLOR=#000000]}[/COLOR] \</p\>  
\<p\>&nbsp;\</p\>  
\<p\>[COLOR=#000000]}[/COLOR]\</p\>  
\<p\>Key.[COLOR=#0000ff]addListener[/COLOR]COLOR=#000000[/COLOR];\</p\>  
\<p\>  
[/LEFT]  
[/FONT]

Can someone see what I am doing wrong?
