Text Entry Wildcard/Lose Focus workaround

Have you ever found yourself wanting to evaluate a Text Entry field WHILE the user was typing? Frustrated by the inability to do that? Me too.

I stumbled upon something today that didn't work as I expected it to, but might be a workaround.  Here is the situation: I'm creating a simulation where I want the user to enter "2541261" in a text entry field. If this was a stand-alone task, I would simply add a "submit" button of some kind and evaluate the entry when the button is clicked. However, this is just one of a series of steps, so I don't want that additional button. Rather once the number is entered, the instructions for the next step should appear.

In a previous version, the user was supposed to enter a different number: "2541263", so I simply assumed they typed in the correct number and triggered something when the user pressed 3 key or Num 3 key. Not ideal, but it worked.

I can't do this with the new version, since the user has to press the 1 key or the Num 1 key twice. I attempted to work around by counting the number of times the 1 key or the Num 1 key were pressed, by creating a variable (inputCharCount) and incrementing it (+1) each time the 1 key or Num1 key are pressed.

Here's where it gets interesting...

The variable doesn't increment when I hit the 1 key. Instead, it is assigned whatever has been entered in the text field before the 1 is pressed. The control hasn't lost focus yet, so the TextEntry variable is still undefined, yet I can test whatever the user has typed.

...possibilities!

A few notes:

  • In my example, the inputCharCount variable is set to be a number, so entering other characters messes things up.
  • Even though the trigger occurs when the user presses 1, it only captures everything up to, but not including the last "1" (difference between key down and key up?)
  • I'm only testing the entered text in a rudimentary manner (i.e. inputCharCount >= 254126), but you could do something more sophisticated, including searching strings via javascript.
  • Haven't tested on iOS yet.

check it out:

http://www.deus-ex-media.com/experiments/storyline/text_entry_wildcard/package/story.html

Maybe this isn't news to anyone, but I hadn't seen it before.
Also interested in any other ways you guys have been doing this sort of thing.

thanks!

5 Replies
Maria Costa-Stienstra

Hi, Ross, and welcome to E-Learning Heroes! ✨

When using the trigger "Set textentry equal to the typed value when Text Entry loses focus", it means the variable textentry will be set with the text entered by the user only when something happens outside of that text entry field. 

For example, if I type "123", my variable textentry is still blank. It will only be set as "123" once I click somewhere on the screen, press the Enter key, press Tab, etc., any action that takes my keyboard's focus away from the entry field. 

Take a look at the example below, where the value of the variable (the entered text) is displayed, but it only changes when one of the described actions happen:

Screen Recording 2021-07-08 at 11.38.42 AM

Let me know if this answers your question!