# Matching Words

**URL:** <https://forum.kirupa.com/t/matching-words/25564>\
**Category:** flash\
**Created:** [July 14, 2003, 2:49pm UTC](https://forum.kirupa.com/t/matching-words/25564 "2003-07-14T14:49:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ck3lam](https://avatars.discourse-cdn.com/v4/letter/c/82dd89/32.png) [@ck3lam](https://forum.kirupa.com/u/ck3lam)\
**Post date:** [July 14, 2003, 2:49pm UTC](https://forum.kirupa.com/t/matching-words/25564/1 "2003-07-14T14:49:13Z")

</div>

Does anyone know how to do something like when a key is pressed, if its Ascii code match a dynamic random text( only one character for the moment), it will go to another character. In other words, it will regonized the character i type match the character of the dynamic random text.

Something like the effect of a game called “House of Dead-Typing of the Dead” Hope i didn’t spell wrongly the name of the game!  
Thanx!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 14, 2003, 3:09pm UTC](https://forum.kirupa.com/t/matching-words/25564/2 "2003-07-14T15:09:16Z")

</div>

You can get the ascii of the last key pressed like so:

```auto
Key.getAscii;

```

From there you can compare the letter (in the form of a number value) with a position in an array, containing your letters.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 14, 2003, 3:17pm UTC](https://forum.kirupa.com/t/matching-words/25564/3 "2003-07-14T15:17:54Z")

</div>

When i compare the text with the key i press, i get the Ascii code i pressed but get ‘undefined’ for the text(use trace to check)which i wanna compare. Which means im unable to compare them. It seem it couldn’t read the Ascii code from the random dynamic text. Any idea?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 14, 2003, 3:28pm UTC](https://forum.kirupa.com/t/matching-words/25564/4 "2003-07-14T15:28:39Z")

</div>

well to give you a start, the ascii for the letter ‘a’ is 97 and ‘A’, 65. Based on that, you’re gonna have to deal with an offset for the positions of the elements in the array. for example, if ‘a’ was pressed, in order to access the first element in the array, you’ll have to

```auto
asc = Key.getAscii; // you can try changing this to Key.getAscii(); if it doesn't work
elem0 = yourArray[asc-97];

```

Mind you, this code would only work if the letters pressed were lowercase. And notice I said letters. Other characters will require a bit more code. But play with this first until you get it working and i’ll complete the code including other characters, uppercase, lowercase, numbers, etc.
