Forum Discussion
Key press triggers help
Hello,
I have been trying to use the Control key as my trigger because I am creating a simulation of our system. But Storyline 360 won't take it unless it is paired with another key. Which is not what I want. Is there a way around that? Please help.
5 Replies
- NedimCommunity Member
The Ctrl, Shift, and Alt keys are designed as modifier keys. These special keys, when pressed in combination with other keys, trigger specific actions. The only way to detect when the Ctrl key is pressed on its own (without other modifiers) is to use JavaScript. You can write a script that listens for the Ctrl key press event, and when detected, it changes a variable value to true. Once the variable changes, you can trigger an action, such as jumping to the next slide.
- SamHillSuper Hero
Hi IngridCarrer168 I think they might avoid that due to potential conflict with other system and accessibility tool shortcuts. There could be another reason, just a theory.
Here's the JavaScript to do what you want. Just add this to the timeline start trigger.
document.addEventListener("keydown", function(event) { if (event.ctrlKey) { const player = GetPlayer(); const current = player.GetVar("ctrlkey") !== true; // forcing the "ctrlkey" value to change everytime the CTRL key is selected player.SetVar("ctrlkey",current); } });
Attached is an example of implementation that just triggers an animation every time the CTRL key is selected.
- AlanaBousquetCommunity Member
Is there any way to make this functionality work when doing the simulation in a browser? I tried it in SL and it works just fine, but now that I'm trying the published version in my browser, nothing happens :(
- IngridCarrer168Community Member
I tried it, and it works! You are a lifesaver. Thank you so much SamHill ๐
- AlanaBousquetCommunity Member
IngridCarrer168โ Were you able to get this to work in a browser? I tried the same steps that Sam posted and it worked inside Storyline, but not in a browser :(
Related Content
- 4 months ago
- 25 days ago
- 10 years ago
- 3 months ago