Forum Discussion
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.
- eLearningmLearnCommunity Member
Has anyone came across with this?
Thanks.
- taramoore4Community Member
I have come across it at the same point you are now....I need to create the computer simulation, but don't know anything about javascript and Storyline. Did you get a solution somehow?
- LynnStocksCommunity Member
I think I may have a solution for you.
go to this website
http://www.quirksmode.org/js/keys.html
determine the keycode for the functino key you want to disable (F1 is 112, F2 is 113 etc)
add a trigger to the slide that needs to have the function key disabled to execute javascript.when timeline starts and enter this script.
document.onkeydown = function (e) {
if(e.which == 113){
return false;
}
}
changing the number 113 to whatever the code is for your function key,
it really works
- BCHarperCommunity Member
Just saw this post... Did this actually work for you in the past? I have a similar situation and we have been trying to work around with a virtual keyboard but it is just not realistic for our learners...
- KarelWagnerCommunity Member
This community is so AWESOME!!
I had no idea why my simulation would not advance when I'd press 'F2'. I had my trigger correct but it would not work. The advise provided by Lynn Stocks worked like a charm.
NOTE: I'm not experienced with JaveScript either.
Thank you Lynn!
- SadieGunninkCommunity Member
Just helped a colleague with this very issue and Lynn's suggestion worked like a charm. Thank you! Thank you!! :)
- davidtempletonCommunity Member
Where do you enter this script? I am not fully understanding.
- KarenOpperman-6Community Member
It works! Thanks Lynn. :)
Just a note: if you want to test it, publish to CD format for quickest results.
- PamRobinson-a55Community Member
I have been struggling with this too and need an assist. I have created an AS400 step-by-step simulation in Storyline 2 that requires users to press the F4 or F6 key to move to the next slide. I have executed this javascript: document.onkeydown = function (e) {if(e.which == 115){return false;}} for F4. (I changed 115 to 117 for F6) They appear to be disabled but they don't advance to the next slide, even when I add a second trigger to jump when the user presses the key.
Any ideas?? My workaround of placing a hotspot over the function onscreen to jump fell flat with my test group because they were able to execute other activities using their keyboard in the training.
Thanks in advance!
- KarenOpperman-6Community Member
Hi Pam, almost all of my work-arounds were successful except for the F2 and F3 for the simulations I created. In the end I didn't use them, but instead added the follow comment:
"In the live environment, press F2 to continue. For this example, press Enter."If anybody else has a solution to this problem, I'd love to know as well!
- WaltGillCommunity Member
Yeah, I also tried using that javascript and it will not work. I wish there was a solution to this.