Set TextEntry to the typed value when user presses the enter key

Hi there

I am working with a simulation and i have text entry fields where once the user has typed in the information, the user must press the enter key.  Once the enter key is pressed, it must set the TextEntry variable to whatever the user has typed. The only option here is to set the variable once the control loses focus, but in this case the control never loses focus. 

23 Replies
Crystal Horn

Hi Lizzy.  Welcome to Heroes!

The enter key should behave in the data entry fields as follows:

*  If the data-entry field is tall enough to accommodate more than one line of text, the Enter key will add a line break (return), so the learner can start a new paragraph.  Is this the case with your field; is it large enough that it is moving to another line?

*  If the data-entry field is only tall enough for a single line of text, the Enter key will assign the learner's response to the text field's variable. In other words, it'll submit the learner's response.

If you'd like the Enter key to always submit the learner's response, regardless of the size of the data-entry field, add another trigger to the data-entry field that adjusts the variable when the User presses a key, and specify the Enter key.

You can read more about the Enter key here.  Let us know if that helps!


lizzy vdm


Thank you for your response.  

While the enter key does submit the response (since my data entry field is only tall enough for one line) it does not adjust the variable.  

How do i create a trigger to adjust the variable to what the learner has typed in? If I create a trigger to adjust the data entry variable i can adjust it to what the correct response is yes, but then the learner will be able to type in anything he/she wants to as the enter key will simply adjust the variable to what it needs to be.

lizzy vdm

My project works with levels ans scores.  For each correct hotspot click the learner has points added to the score.  The amount of point added is based on the level the learner is on. 

Same as for the correct click, the learner must get points added to the score if he/she entered the correct text.  While i can get it to submit the text entry by pressing the enter key, i cannot get it right that the text entry adds points to the score.

So for example the trigger at the moment is;

Add Level0 to Score when the user presses the Enter key if Score is less than or equal to 49.

I tried adding another condition to say

And If TextEntry is equal to the correct response

But that doesn't work as the TextEntry variable is never adjusted to what the correct response is, as the control never loses focus.  

I attached an example of the project for better understanding. 


Crystal Horn

Hi Lizzy.  So I was able to get it to work with some trigger and conditions adjustment when the score was under 50, but it would not work for me when the score was between 50 and 239.  Check out my screenshot to see the triggers and conditions I modified under the "Object Triggers" heading.   It did work when I used Storyline 2, which gave me some hope that there is a way.

At this point, I would advise you to Submit a Case to our Technical Support staff so that they can work with you to find a fix.

Keep us in the loop with your progress!

lizzy vdm

Hey, i tried your solution as per your screenshot but this still did not work for me on any of the levels. 

What I did end up doing was create the same add to score triggers on the next slide to adjust the score when timeline starts as the learner will not enter this slide unless the correct answer was entered. 

Thank you for your assistance.

Stuart Gilbert

if anyone is still around for this thread, i have a question on using the Enter key with a text entry field. i'm using SL 360.

i would like the learner to enter a character string into a text entry field (with no room for additional lines) and then either click the search icon or hit Enter. however, the Enter key portion just isn't working.  it jumps to the next slide (as it should) when the hotspot is clicked, but not when the Enter key is being used. 

I have attached the slide. i may (probably) have overdone it with a couple of my triggers, so i apologize for that. but if someone could possibly take a look at this and give me any suggestions, it would be greatly appreciated. 

thanks very much.

stuart gilbert

Christiana Awojinrin

Hi there, I have a similar problem to Lizzy but Crystal's answer showed up an inconsistency in the way SL 360 behaves.   I have a simulation that features text entry fields. I'm getting the following: 

  1. Type the correct value and then press my substitute Submit button (simply a hotspot): the Correct layer shows.   YAY!
  2. Type the correct value then press the ENTER key: the Correct layer shows.  YAY!
  3. Type the incorrect value and then press my substitute Submit button: the Incorrect layer shows.  YAY!
  4. Type the incorrect value then press the ENTER key: text wraps in the field.  You wha…?

I have played about with just about every possible permutation of data-entry field height, text wrap options and triggers that (tried to) assign to the variable when the ENTER key is pressed but I still cannot resolve the anomaly that causes SL to handle correct and incorrect values differently. 

On my Form View: my Submit Key is the ENTER key, and the Field to Evaluate is my text entry field with my hotspot as my submit button.  I am using standard (not custom) Incorrect and Correct layers.

My current triggers that give me 1-4 as shown above are pasted below:

My current triggers

Note that I had to add a trigger to show the Incorrect layer when the user clicked my "Submit" hotspot with the wrong value as that functionality, unlike the processing of the correct value, did not appear to be built in.  That was how I got item 3 (above) to work but  item 4 is proving harder to resolve by such means.  I've  tried creating triggers that assign the user entered value to my variable when the user presses the ENTER key but this usually results in ALL entries (1-4) resolving as Incorrect!  I've tried "Wrap Text in Shape" on and off. I've also tried to see if having a ridiculously tall, prohibitively squat or perfectly-sized text entry field makes a difference! None, nada, argggh!!!  I have run out of ideas and possible permutations!

It seems an anomaly to me that valid values are processed fine by the auto-generated Set <variable> ... trigger and the Submit Interaction … trigger, but invalid values are not. 

Why does pressing  the ENTER key with a valid value in the field have the desired effect, but doing the same with an invalid value simply wraps the text??  Is it a bug? Something to do with imprecise handling of the typed value when the text field doesn't lose focus?  

I'm off now to make some tea, drink it slowly, play Two Dots on my phone and calm down. And, when I return to this forum, a bright spark (or three) will have pointed out something really blatantly obvious that I have neglected or done wrong.  And rather than feeling very, very stupid, I will be eternally grateful for your help as this is very frustrating!    

Christiana Awojinrin

Hi again 

re: "If the data-entry field is only tall enough for a single line of text, the Enter key will assign the learner's response to the text field's variable. In other words, it'll submit the learner's response."

Let's say I have a 14 point Calibri font: how tall should my data-entry field be to submit invalid text rather than wrapping it?  

I have played with a variety of different data-entry field heights including those so short that the text appears truncated! But all result in an invalid value being wrapped when the ENTER key is pressed, while valid values are correctly submitted on the user pressing ENTER.

Off to have some coffee … bored with tea now! 

Leslie McKerchie

Hello Christiana,

Thanks for popping in to share what you are experiencing in your course as well.

With your permission, I'd like to take a look at your project file to investigate what's happening. You can share it publicly here, or send it to me privately by uploading it here. I'll delete it when I'm done troubleshooting. Be sure to point me to the slide you've referenced above.

Colin Defty

Hi Leslie,

Thanks for responding. I have shared an example of the problem on review.

To summarise:

  1. Enter 002201939 (right answer) then click Search: Tick
  2. Enter 002201939 (right answer) then press ENTER: Tick
  3. Enter 002hdjhhe (or any wrong answer) then click Search: Cross
  4. Enter hgdgfhgfe (or any wrong answer) then click ENTER: text wraps!

Any advice to fix 4 would be greatly appreciated!

Kind regards

Jennifer Bircher

Hello - I am having the issue that was originally raised in this post years ago. I have a text-entry field that will not lose focus when the user presses Enter. According to previous responses to this post, the following should happen:

*  If the data-entry field is tall enough to accommodate more than one line of text, the Enter key will add a line break (return), so the learner can start a new paragraph. 

*  If the data-entry field is only tall enough for a single line of text, the Enter key will assign the learner's response to the text field's variable. In other words, it'll submit the learner's response.

My text entry field is only tall enough for a single line of text, but pressing the Enter key does not assign the learner's response to the field's variable. In addition, input text continues to scroll horizontally within the field if I continue typing. I tried adjusting the Text Box properties, such as turning off Wrap Text and selecting Do Not Autofit, but I got the same result.

All of this also happens in a numeric entry field. Same result in both Preview mode and when published.

I see that I could add a trigger to the Text Entry variable to change when user presses the Enter key, but would prefer to use Storyline's native functionality.

I'm sure I'm missing some obvious setting, but any advice would be appreciated. Thanks!!

Ren Gomez

Hi Jennifer,

I'm sorry to hear you're running into this issue. Are you using a screen recording, a numeric entry question, or a regular slide for your interaction?

If you used a screen recording or numeric entry quiz slide, you should be able to switch to Form View and use the Enter key in the Submit Keys section.

To give us a better idea of how to move forward, feel free to share your file with our Support Team, and they'll lend a hand in getting your interaction set up correctly!

Jennifer Bircher

Thanks, Phil! The client prefers no Javascript, but if nothing else works I will certainly try this. I'm planning to send my SL tile to the Support Team this evening. Based on the documentation, it seems that Enter should be working. Also, I just determined that pressing the Enter key does work when the value entered is incorrect. The plot thickens...

Quentin Roper

Thanks very much Phil, your solution fixed my problem with a text-entry quiz when students use iPads.  This problem didn't occur on computers, just on touch devices.

The textEntry field wasn't losing focus and setting its variable when the first subsequent tap was on the submit button. The questions are already based on javascript/regex triggers so I added in your code at the top line and it works fine on iPad now. 

Sharon Goza

What should the rest of the trigger be?  When I try to add an execute Javascript on a keypress it makes me pick "after clicking..."   Should that be the enter field?    I really just want to be able to have the number update only when the user hits enter in the enter field,  I'm hoping I don't have to resort to a "submit" button, especially since this is for 5th graders.