Forum Discussion

eLearningmLearn's avatar
eLearningmLearn
Community Member
12 years ago

Function Keys Interactivity in Storyline Using JavaScript

I am creating simulation for a software in storyline. This simulation has function keys interactivity - F2,F3,F10,F11.

I was able to write trigger code - Jump to Slide when user presses F3 keys.

When I am publishing this project, the function keys are responding to the browser function keys. e.g. when I press F3, instead of going to slide F3, its showing browser's find feature.

I tried to do research on google and articulate forum for how to use functions for simulation its leading me JavaScript.

I understand that I need to use trigger - Excute JavaScript in Storyline.

But I don't know how to write a javascript.

I need JavaScript which will disable browsers function key e.g. F3 and if user presses F3 it should go to the next slide.

I guess I need two JavaScripts; the one which will disable browser's function key, and the other which will assign the user defined function that is go to F3 slide if user presses F3 funciton key.

I know there are tons of website which will give you javascript code. But I find it difficult execute in the Storyline.

I have created an example and uploaded the storylline file in this message.

Please help me to write the javascript in storyline.

Thanks in Advance.

  • Owen,

    I assume I'll need to include the Execute Java Script trigger, correct? If I could ask a stupid question - What JavaScript does it execute, and where does it get it from?

    Thanks very much.

    Stuart

    • MichaelHinze's avatar
      MichaelHinze
      Community Member

      When you open the F-Key_Test_V360.story file Owen had shared, you'll see an Execute Javascript trigger. Double-click the trigger and then click on the Script --- button to see the script that is being executed.

  • Thanks for the assist Michael. I'm not sure why/howIi became unsubscribed to this thread. (Or maybe work is marking email as spam?)

    • RandyCruz-d1283's avatar
      RandyCruz-d1283
      Community Member

      Hi Owen - this is genius! Wondering if there are any scripts to also disable the arrow keys? My interaction required the down arrow to show slide layers using the press key trigger. Seems to work on the first layer but i can't keep pressing the down arrow AND move up several layers. It breaks after the first. Any thoughts? 

  • JodiSansone's avatar
    JodiSansone
    Community Member

    Hi to all the smart people on this thread. I recognize all of you from other places in the community.

    I just was directed here by Joe Tansengco and I can't figure out how to apply the insights here as my javascript skills are limited.   I tried following the conversation but I can't untangle it.

    I am working on a free form question interaction that is a text entry question.  I noticed that if I hit the Enter key to advance to a new line within the text entry box, the "Thank you" layer pops up prematurely.  I was hoping there would be a way to avoid this or disable the enter key for this interaction.  I think learners may hit Enter to advance to a new line if they are typing.  We are not trying to track the response as correct/incorrect so I just chose a "Thank you" layer once the interaction is completed.  As I understand it, my client's LMS has the capability to see what people have typed--they don't need it graded, they just want visibility into what people have typed.   Maybe I just have my question set up incorrectly.  If there is a better way to do this, I'm open to it.  I was even looking at using the built-in survey question as an alternative.  Any ideas?  I attached my file for reference.  Thank you!

    • MathNotermans-9's avatar
      MathNotermans-9
      Community Member

      Hi Jodi,

      First i tried to get it fixed using Javascript, but soon noticed that especially the built-in questions in Storyline are very tied up in the code of Articulate, thus sometimes hard to change. So i reworked your sample to using a normal input textfield...and then it works nice without any need for Javascript.

      Basically i just added a normal textinput field and used the data in that to change the values of the question textArea input. Then internally the submit doesnot get triggered and all works fine.


  • JodiSansone's avatar
    JodiSansone
    Community Member

    Thank you Math. I appreciate the time  you took to help me work through this. I think I might try using the short answer survey or essay survey question too.  My client wants to read the response in the LMS and the survey questions don't have that Enter key issue.  On the positive side, I learned if you press shift+Enter you can advance a line in the text graded question without submitting the interaction, but that's an extra step.   Have a happy New Year!

  • VTSub's avatar
    VTSub
    Community Member

    Hi All,

    How can we restrict the use of Enter key for submitting Numeric Entry? What could be the best workaround? I have already tried adding layer but it is bypassed and JS doesn't work either. Please help.

    Thanks in advance!

     

    • SarahHodge's avatar
      SarahHodge
      Former Staff

      Hello Vt Sub! Welcome to the community! I saw a similar thread over here about the Enter key in case you want to check it out. A few community members shared their solutions there. 

      • VTSub's avatar
        VTSub
        Community Member

        I have already checked and tried out these, but seems it cannot be controlled.

  • VTSub's avatar
    VTSub
    Community Member

    Any other solution, Sarah? No luck here :(