Checking input response by keypress #/key position in string VAR
June 24, 2010 12:00 AM
Hi all,
I'm not sure why I'm not able to find this information, but I'm sure it's my query -- If this has been asked, just redirect me ;)
I'm trying to create input which tests keystrokes and compares them to a "response" variable (string). Once the user presses a key that doesn't "match," it immediately kicks them out of the interaction.
Example:
required response: Lectora
If the user types: Leck -- they are now kicked out of the loop (the K should be a T)
Here's what I'm currently capturing:
-- how many numbers of keys have been pressed (probably not necessary for this since i should be able to pull from the INPUT data)
-- entries into the form input box
-- variable contents (correct response)
Is there a way to do something like:
//capture recent key pressed and position in the array combo
(so input Leck would be something like [Input_001 1, L 2, E 3, C 4, K ]...)
//compare the array with a response key combination/position key combo in another variable
response required: lectora
1, L (ok)
2, E (ok)
3, C (ok)
4, K (uh oh!)
This shouldn't be that hard -- I'm just not sure how to call location of a string within a variable. Can something like
if ThisKeyPressed == (VAR(theCorrectResponse), 4) be used? (checking the most recent key pressed and comparing it with the 4th place in the theCorrectResponse variable).
What I can't seem to figure out is how to compare the two with each keypress in a way that doesn't require a gazillion interactions (we've all done those workarounds ;) )
Thanks in advance for any direction you can provide.
Lisa
Discussions have been disabled for this post